You nest IF functions in Excel by placing one IF function inside another where an IF's value_if_true or value_if_false argument would normally go, so a single cell can return a different result for several possible cases. The pattern is =IF(test1, result1, IF(test2, result2, IF(test3, result3, fallback))). Each inner IF lives inside the previous one's third argument, and the last IF supplies a catch-all value so nothing returns FALSE and nothing hits Excel's limit of 64 nested functions. The modern alternative is IFS, but nested IF still matters for older workbooks and any Excel version before 2019.
What You'll Need
- Excel 2016 or later on desktop (Windows or Mac), Excel for the web, or Excel on iPad. Older versions support nested IF too, but not the IFS function.
- A spreadsheet with a numeric or text value to evaluate and a clear idea of the cut-offs or labels you want returned.
- Two minutes to plan the order of the conditions before you type anything, because nesting order changes the answer.
Step-by-Step
- Decide the order of the tests. Nested IF evaluates left to right and stops at the first TRUE. If you are grading scores, decide whether the highest band or the lowest band comes first. Testing highest first is safer, because once a value passes 90 it never reaches the test for 80. Reversed order silently mislabels everything.
- Write the outer IF first. Click the cell, type
=IF(, then the first test, a comma, the result if true, and a comma. For a grade sheet in A2:=IF(A2>=90,"A",. Do not close the bracket yet. - Start the second IF inside the false argument. Without closing the bracket, type
IF(again. So far:=IF(A2>=90,"A",IF(A2>=80,"B",. This is the nesting itself: the inner IF is just the value Excel should return when the first test fails. - Keep going for each band, in descending order. Continue the same way for C and D:
=IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C",IF(A2>=60,"D",. - Close with a catch-all and the right number of brackets. Finish with the fallback and one closing bracket for every IF you opened:
...IF(A2>=60,"D","F")))). Four nested IFs means five brackets total, counting theIF(function calls returned as values and the final close of the outermost one. Count them rather than guessing. - Press Enter and check one row by hand. Confirm a score of 85 returns B, not C or A. Test the exact boundaries too: a score of exactly 80 should return B, which is why the operators are
>=. If 80 returns C, your order or your operators are wrong. - Copy the formula down. Select the cell, use the fill handle at its bottom-right corner, and drag or double-click to fill the column. Relative references like A2 shift to A3, A4 and so on. If you need the formula to read from fixed cells instead, lock them with dollar signs (
$A$2) before filling. - Read the formula before you trust it. Select the cell and use the formula bar, or Formula tab > Evaluate Formula to step through each test one at a time. That shows exactly which branch produced the result and is the fastest way to find a misplaced bracket. Labels in the ribbon can differ slightly by version, device and region.
- Consider switching to IFS if you have it. Where available,
=IFS(A2>=90,"A",A2>=80,"B",A2>=70,"C",A2>=60,"D",TRUE,"F")does the same job with no trailing bracket chain and is far easier to read. TRUE as the final test acts as the catch-all.
Common Mistakes
Testing in the wrong order. Putting the low band first means every value passes the first test and comes back as F or D. Always go from most restrictive to least restrictive.
Bracket mismatch. Excel offers to fix the formula for you when you forget a closing bracket, and that auto-correction is often wrong at the end of a long chain. Count the IF( openings and match the closes yourself.
Missing the catch-all. If the last IF has only two arguments, any value failing every test returns the logical value FALSE. Put a quoted text label or a 0 in the final result slot.
Comparing text instead of numbers. If your scores were pasted in as text, A2>=90 can be TRUE for "9" because text compares differently. Check with ISTEXT or look for the green triangle error marker in the corner of the cell, then convert the column to numbers.
Forgetting quotes around text results. "A" with quotes returns the letter. Without quotes, Excel treats A as a cell reference and returns an error or the wrong value.
Hard-coding values you will change later. Typing 90, 80 and 70 into four formulas means editing every formula when a cut-off changes. Reference a small lookup table instead.
Tips
- Write the formula across several lines in a text editor first. Excel's formula bar accepts line breaks (Alt+Enter on Windows, Control+Option+Return on Mac) which makes deep nesting readable.
- For anything beyond three or four branches, a lookup table with VLOOKUP or XLOOKUP with approximate match is cleaner, faster to maintain, and less likely to break when someone edits it.
- Use AND and OR inside a single IF instead of nesting when the logic allows:
=IF(AND(A2>=60,A2<70),"D",...)reads more clearly than two stacked IFs, and combined with one nested IF it can replace a whole chain. - Keep all branches returning the same data type where you can. A column that returns some numbers and some text is hard to sort, sum or chart.
- Name the cell holding a cut-off value (Formulas > Define Name) so the formula reads
IF(A2>=PassMark,...)and updates everywhere at once.
Troubleshooting
"The formula you typed contains an error" pop-up. Usually a missing comma or bracket. Use Evaluate Formula to step through and see where it stops, or retype the formula in one go from a plain-text copy.
#VALUE! error. One branch is doing arithmetic or comparison on text. Check the cells feeding the tests, and remove stray spaces with TRIM.
Every row returns the same wrong answer. Your first test is probably too broad, or a cell reference is absolute when it should be relative. Click a filled cell and check whether the row references shifted as intended.
Correct result appears but FALSE shows for some rows. Those rows fall past your last IF. Add a catch-all value to the final argument.
Formula is too long to manage. Break it up: put the individual tests in helper columns, then reference the helpers in a short IF, or replace the chain with IFS or a lookup table. That is not a downgrade, it is easier to audit.
If that did not work, rebuild the formula one branch at a time, confirming after each addition, rather than editing a broken five-level formula in place.
Frequently Asked Questions
How many IF functions can I nest in Excel?
Excel allows up to 64 nested functions in one formula, but anything past three or four levels is difficult to read and audit. Use IFS or a lookup table instead once you pass that point.
What is the difference between nested IF and IFS?
Both evaluate tests in order and return the first match. IFS lists each test and result as pairs with no bracket pile-up, but it is not available in Excel 2016 or earlier, where nested IF still works.
Can I use text conditions inside a nested IF?
Yes. Wrap the text in quotes, for example =IF(B2="Yes","Approved",IF(B2="No","Rejected","Pending")). Text comparisons in Excel are not case-sensitive by default.
Why does my nested IF return FALSE?
The final IF is missing its third argument, so any value failing every test returns the logical FALSE instead of a label. Add a quoted result or 0 to the end.
Should I test the highest value first or the lowest?
Highest first when using >= comparisons, because the formula stops at the first TRUE. Testing the lowest band first means every number in scope passes it immediately.
Does nested IF work in Excel for the web and on mobile?
Yes, nested IF and IFS both work in Excel for the web and the iPad app, though long formulas are harder to edit on a touch screen. The desktop app is better for building and debugging them.