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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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