# Nested IF with IFs within

#### cfieser

##### New Member
I am stuck. I have tried searching, but I am more than likely searching with wrong words.

Is it possible to do an IF within an IF?

Example:

=IF(\$F\$41="ABC",IF(OR(\$I\$60>P133),O134-O133,IF(\$I\$60<O133,0,\$I\$60-P132),IF(\$F\$41="DEF",IF(OR(\$I\$60>P141),P141-O141,IF(\$I\$60<O141,0,\$I\$60-P140)))))

I have 3 more like " ABC" to add to the formula, but what I am trying isn't working.

Thank you!

### Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
cfieser,

Yes it is possible.

It's not clear to me how you are wanting to make your tests. e.g. you only have one element in your ORs and is there an operator missing in... (\$I\$60P141) ?

Here is an example of a nested if...

=IF(\$F\$41="ABC",IF(OR(B41="Y", C41="Y"),"Is ABC and Y","Is ABC but not Y"),"Is Not ABC")

Hope that helps.

Yes, e.g.
Code:
``=IF(A1>2,B1,IF(C1<10,D1,””))``
The result is the value in B1 if A1>2, else if C1<10, the value from D1, else blank(“”).

I have no clue about your case as the formula is incomplete and mixed up as you didn't put the formula between CODE tags.
Also strange to have an OR function with only 1 argument.

Update: well this is quite similar to the concurrent post from Snakehips.

Last edited:
Here is the op's original formula as posted:

=IF(\$F\$41="ABC",IF(OR(\$I\$60>P133),O134-O133,IF(\$I\$60<O133,0,\$I\$60-P132),IF(\$F\$41="DEF",IF(OR(\$I\$60>P141),P141-O141,IF(\$I\$60<O141,0,\$I\$60-P140)))))

Yes, you can nest a large number of IF functions together. Doing so can give you a headache while your brain tries to track all those trues and falses. There are easier ways to conduct such operations; usually, comparing arrays of cells is the better way. So why don't you post an example of your spreadsheet and state your objective and someone might me able to help you?

Here is the op's original formula as posted:

=IF(\$F\$41="ABC",IF(OR(\$I\$60>P133),O134-O133,IF(\$I\$60<O133,0,\$I\$60-P132),IF(\$F\$41="DEF",IF(OR(\$I\$60>P141),P141-O141,IF(\$I\$60<O141,0,\$I\$60-P140)))))

The second IF has 4 arguments (1 too many).

Edit: I tried to highlight the 4 parts, but this ruined the formula. I hope my point is clear though.

Hint: if you are entering formulas, you get a popup indicating the formula elements. If you click such an element, you can see exactly which part of your formula makes up that specific element.

Last edited:
I think my brain is already starting to hurt with trying to make it work and that could be why my post didn't make complete since.

Ex:
Cell F\$41 is a drop down with 6 possibilities

If that cell (F41) = ABC then have the formula look at I60, IF I60 is > P140, O142-O141, IF I60 < P140 return 0, otherwise subtract I60 from P142.

I can get the 2 statements to work on there own, but not together.

Maybe you mean that IF I60 > P140 then O142-O141 else 0?
If so, and if I understand the explanation correctly, I would restucture the formula to:
Code:
``=IF(F41<>”ABC”,P142-I60,IF(I160>P140,0142-O141,0))``
In general I think it’s easier to read when you have the nested IF-statement in the “value if false” part of the first IF-statement.

Replies
1
Views
229
Replies
2
Views
233
Replies
5
Views
414
Replies
1
Views
1K
Replies
6
Views
457

1,203,174
Messages
6,053,932
Members
444,694
Latest member
JacquiDaly

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