nested IF

ritters

New Member
Joined
Jun 16, 2010
Messages
8
I want to try an nest an IF so i can have several conditions on a cell.

is there a formula possible for the below assumptions?

((IFA2=9 or 10, then = 1, IF(A2=7,8, or 12, then =2, IF(A2=3,or 4, then =3, IF(A2=5,6, or 13, then = 4))

Thanks
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Nested IF for below would be:
Rich (BB code):
=IF(OR(A2=9, A2=10),1,IF(OR(A2=7,A2=8,A2=12),2,IF(OR(A2=3,A2=4),3,IF(OR(A2=5,A2=6,A2=13),4,"Default"))))
Default is when nothing matches, though you can change that to anything you want.
However, I'd be more tempted to create a table with numbers 1 to 13 in one column and the required value next to them, e.g.

1 Default
2 Default
3 3
4 3
5 4
6 4
7 2
8 2
9 1
10 1
11 Default
12 2
13 4

And then use a VLOOKUP formula based on this table instead of a nested IF formula. It would make changing values easier too.
 
Upvote 0
I want to try an nest an IF so i can have several conditions on a cell.

is there a formula possible for the below assumptions?

((IFA2=9 or 10, then = 1, IF(A2=7,8, or 12, then =2, IF(A2=3,or 4, then =3, IF(A2=5,6, or 13, then = 4))

Thanks

Try something like...

=LOOKUP(A2,{0,3,5,7,9,11,12,13},{"?",3,4,2,1,"??",2,4})
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,007
Members
448,935
Latest member
ijat

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