Excel 'IF' statement help
Author
Discussion

skinnyman

Original Poster:

1,895 posts

123 months

Thursday 26th February
quotequote all
I have a spreadsheet with 3 columns.

Column a will show either 'A' or 'B'
Column b will show either '1' or '2'

In column C I need:
"IF(column a=A & column b=1) then do this
"IF(column a=A & column b=2) then do this
"IF(column a=B & column b=1) then do this
"IF(column a=B & column b=2) then do this

How do I get that all into 1 IF statement? I can do basic IF & AND statements, but they usually have "if true do this, if false do this", but in this instance there won't be a 'false'.

Harpoon

2,527 posts

244 months

Thursday 26th February
quotequote all
Hopefully I've understood correctly, in which case, use nested IFs. The false part of the IF becomes the start of another IF

https://exceljet.net/formulas/nested-if-function-e...

Mazinbrum

1,378 posts

208 months

skinnyman

Original Poster:

1,895 posts

123 months

Thursday 26th February
quotequote all
Harpoon said:
Hopefully I've understood correctly, in which case, use nested IFs. The false part of the IF becomes the start of another IF

https://exceljet.net/formulas/nested-if-function-e...
That has worked perfectly, thankyou!

alock

4,559 posts

241 months

Thursday 26th February
quotequote all
With lots of values, a switch might become easier to manage, e.g.

=SWITCH(CONCAT(A1,B1), "A1", "output for A+1", "A2", "output for A+2", "B1", "output for B+1", "B2", "output for B+2")

Mr Pointy

13,386 posts

189 months

Thursday 26th February
quotequote all
Instead of nested IF functions look at the IFS function:

https://support.microsoft.com/en-us/office/ifs-fun...

JimM169

820 posts

152 months

Friday 27th February
quotequote all
alock said:
With lots of values, a switch might become easier to manage, e.g.

=SWITCH(CONCAT(A1,B1), "A1", "output for A+1", "A2", "output for A+2", "B1", "output for B+1", "B2", "output for B+2")
How long has the SWITCH function been around !!! Been using Excel for 25+ years and never noticed it before !