TBSupport
asked on
Excel: Nested If, Then Statement
Hello:
I have an Excel column containing 2s and 3s. I tried creating a "nested If, Then statement" to say If D2 = 2, then make it 3 and if D2 = 3, then make it 2. But, my formula produces the word "FALSE" instead of a number:
=IF(D2="2", "3", IF(D2="3", "2"))
How do I fix this statement to make it how I need?
Thanks!
TBSupport
I have an Excel column containing 2s and 3s. I tried creating a "nested If, Then statement" to say If D2 = 2, then make it 3 and if D2 = 3, then make it 2. But, my formula produces the word "FALSE" instead of a number:
=IF(D2="2", "3", IF(D2="3", "2"))
How do I fix this statement to make it how I need?
Thanks!
TBSupport
ASKER
Hi Randy:
Thanks, for the quick response. But, that produces "2" and not "3".
TBSupport
Thanks, for the quick response. But, that produces "2" and not "3".
TBSupport
I have this formula on Cell E2, if I enter 2 in cell D2 then E2 shows 3, if I enter 3 in cell D2, E2 shows 2...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> =IF(D2="2", "3", IF(D2="3", "2"))
You need two commas per IF. So you are missing last 'ELSE' before the double parens
> if I enter 2 in cell D2 then E2 shows 3, if I enter 3 in cell D2
Should work for that.
Question remains, what if you enter something other than a 2 or a 3?
Maybe this is better:
Where this is an attempt to just end up switching two values already present in column D, then use
***
and the other values {1,4,5,6...a,b,c,...} will remain in place
- and if so, heed teylyn comment and ensure values present in sheet that are supposed to be common really are - clean it up with functions like trimming, ensure all cells are formatted to text, or whatever.
You need two commas per IF. So you are missing last 'ELSE' before the double parens
=IF(D2="2", "3", IF(D2="3", "2","?"))
> if I enter 2 in cell D2 then E2 shows 3, if I enter 3 in cell D2
Should work for that.
Question remains, what if you enter something other than a 2 or a 3?
Maybe this is better:
=IF(D2="2", "3", IF(D2="3", "2"," "))
or
=IF(D2="2", "3", IF(D2="3", "2",""))
This also works, but produces little -> what else do you want to do?or
=IF(D2="2", "3", IF(D2="3", "2",""))
Where this is an attempt to just end up switching two values already present in column D, then use
***
=IF(D2="2", "3", IF(D2="3", "2",D2))
***and the other values {1,4,5,6...a,b,c,...} will remain in place
- and if so, heed teylyn comment and ensure values present in sheet that are supposed to be common really are - clean it up with functions like trimming, ensure all cells are formatted to text, or whatever.
@Sunbow:
>> You need two commas per IF.
No you don't. The false argument can be omitted. You just need to understand the implications.
>> what if you enter something other than a 2 or a 3?
According to the question that is not a concern.
>> You need two commas per IF.
No you don't. The false argument can be omitted. You just need to understand the implications.
>> what if you enter something other than a 2 or a 3?
According to the question that is not a concern.
Open in new window