How To Properly Nest IF Statements

honkin

Active Member
Joined
Mar 20, 2012
Messages
385
Office Version
  1. 2016
Platform
  1. MacOS
hi

I have 3 consecutive columns which will either have an X or be blank. I have 3 IF statements which cover all possible scenarios, but am struggling to nest them properly into one formula.

This first one tests if the sequence of the 3 columns is XX
Code:
=IF(AND(T2="X",U2="X"),"**","")

This one tests if the sequence is X Blank
Code:
=IF(AND(T2="X",U2=""),"*","")

This last one tests if the sequence is Blank Blank X
Code:
=IF(AND(T2="",U2="",V2="X"),"x","")

So I end up with either **, * or x in the cell. Naturally if there is nothing in all 3, I get a blank.

Firstly, how to best nest these 3 and secondly, is it actually the best way? I mean, can the SWITCH function be used with AND? Just after the most reliable way to do what I am after

Thanks in advance
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Code:
=IF(AND(T2="X",U2="X"),"**","")
This one tests if the sequence is X Blank
Code:
=IF(AND(T2="X",U2=""),"*","")
This last one tests if the sequence is Blank Blank X
Code:
=IF(AND(T2="",U2="",V2="X"),"x","")
-------
=IF(AND(T2="X",U2="X"),"**",IF(AND(T2="X",U2=""),"*",IF(AND(T2="",U2="",V2="X"),"x","")))

I assume for the first 2 conditions V does not matter what it is

and that T2 = "" , U2 = "X"
also does not matter
 
Upvote 0
=IF(AND(T2="X",U2="X"),"**",IF(AND(T2="X",U2=""),"*",IF(AND(T2="",U2="",V2="X"),"x","")))

I assume for the first 2 conditions V does not matter what it is

cheers Etaf.
Yes, V made no difference withe the first 2. That works brilliantly.
Thanks so much
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top