Excel 'IF' statement help
Author
Discussion

skinnyman

Original Poster:

1,868 posts

115 months

Yesterday (13:34)
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,402 posts

236 months

Yesterday (13:40)
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,209 posts

200 months

skinnyman

Original Poster:

1,868 posts

115 months

Yesterday (13:49)
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,478 posts

233 months

Yesterday (13:51)
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

12,769 posts

181 months

Yesterday (16:12)
quotequote all
Instead of nested IF functions look at the IFS function:

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

JimM169

772 posts

144 months

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 !