# nested IF

#### ritters

##### New Member
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

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

#### JackDanIce

##### Well-known Member
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.

##### MrExcel MVP
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})

Many thanks

Replies
19
Views
134
Replies
4
Views
193
Replies
4
Views
225
Replies
2
Views
118
Replies
3
Views
146

1,127,730
Messages
5,626,552
Members
416,190
Latest member
plee3

### 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.

### Which adblocker are you using?

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

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