Excel guide · 3 min read
How to write a nested IF in Excel
A nested IF puts a second IF in the "value if false" slot of the first: =IF(B2>=100,0,IF(B2>=50,4.99,9.99)). Excel checks the first condition, and only if it is FALSE moves on to the next IF. Test the strictest condition first and close one bracket per IF.
Sample data
Every formula on this page was calculated live against this sheet.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Order | Total | From | Shipping | |
| 2 | SO-2201 | 72.5 | 0 | 9.99 | |
| 3 | SO-2202 | 134 | 50 | 4.99 | |
| 4 | SO-2203 | 18.9 | 100 | 0 | |
| 5 | SO-2204 | 49.99 | |||
| 6 | SO-2205 | 100 | |||
| 7 | SO-2206 | 260 |
Start with one IF, then nest the next
Write the rule in plain words first: orders of $100 or more ship free, orders of $50 or more pay $4.99, everything else pays $9.99.
The first IF handles free shipping. Its false branch is where the rest of the rule goes, so you drop a second IF there. Type the whole thing, then count: two IFs means two closing brackets at the end.
- Type =IF(B2>=100,0, for the first band.
- Instead of a final value, type IF(B2>=50,4.99,9.99) for the remaining bands.
- Close the outer IF with one more ) and press Enter.
- Double-click the fill handle to copy it down the column.
Result: 4.99
Order SO-2201 is 72.50. It fails the 100 test, passes the 50 test, and returns 4.99.
Why order matters
Excel stops at the first TRUE condition. If you test the loose condition first, the strict one never gets a chance. This formula is valid but wrong: a $134 order passes B2>=50 first and is charged $4.99 instead of shipping free.
Rule of thumb: when testing "greater than", go from the highest threshold down. When testing "less than", go from the lowest up.
Result: 4.99
SO-2202 is 134, but the first test (>=50) is already TRUE, so it wrongly returns 4.99.
Going deeper: four or more levels
Each extra band adds one more IF in the last false slot. Excel allows up to 64 nested IFs, but anything past four or five gets hard to read and easy to break.
Here is a four-band version. Notice the shape: the final value 9.99 sits at the very end, followed by one closing bracket per IF.
Result: 0
SO-2206 is 260, so the first test passes and shipping is 0.
Cleaner alternative: IFS (Excel 2019 and later)
IFS takes condition and result pairs side by side, so there are no brackets to count. End with TRUE so anything that matches nothing still gets a value.
Result: 9.99
SO-2203 is 18.90, fails both tests, and lands on the TRUE catch-all: 9.99.
Best for many bands: a lookup table
Put the thresholds in a small table (D1:E4 here, sorted from smallest to largest) and look up the total with an approximate match. Changing a price now means editing a cell, not a formula.
XLOOKUP with match mode -1 finds the exact value or the next smaller one. In older Excel, =VLOOKUP(B5,D2:E4,2,TRUE) does the same thing as long as the table is sorted ascending.
Result: 9.99
SO-2204 is 49.99. The next smaller threshold is 0, so the shipping is 9.99.
Common mistakes
Missing or extra closing brackets
Count your IFs and put the same number of ) at the end. Excel colors each bracket pair while you type, which helps you match them.
Gaps between bands
Using >100 in one IF and <100 in the next leaves exactly 100 unhandled. Use >= and let the next IF take everything below.
Numbers stored as text
If the totals came from an export, "72.5" text may compare as larger than any number. Convert them first with Data > Text to Columns or VALUE.
FAQ
How many IFs can you nest in Excel?
Up to 64 in Excel 2007 and later. Microsoft recommends switching to IFS, XLOOKUP or VLOOKUP long before that, because deep nesting is hard to check.
What is the difference between nested IF and IFS?
They give the same results. IFS lists conditions side by side and needs no nesting, but it only exists in Excel 2019, 2021 and Microsoft 365.
Can a nested IF use AND or OR?
Yes. Any IF test can be an AND or OR, for example =IF(AND(B2>=100,C2="US"),0,IF(B2>=50,4.99,9.99)).
Functions used
IFPicks a result from a testIFSFirst true test winsXLOOKUPModern lookup in any directionVLOOKUPVertical lookup
Keep learning
- Excel IF statement with multiple conditions
- Excel formula for letter grades
- How to use IF with AND and OR in Excel
Updated 2026-10-31