The guide · Nested IF
How it works
An IF has a test, an answer for TRUE and an answer for FALSE. In a nested IF, the FALSE answer is another IF. Excel goes through the tests from left to right and stops at the first one that is true.
=IF(B2>=80, "A",
IF(B2>=65, "B",
IF(B2>=50, "C", "F")))
For a score of 72: is it 80 or more? No. Is it 65 or more? Yes, so the answer is B, and the last test is never checked.
Why the order matters
Write the same tests from small to large and every passing student gets a C:
=IF(B2>=50, "C", IF(B2>=65, "B", IF(B2>=80, "A", "F")))
A score of 91 is "50 or more", so the first test is already true and IF stops there. With >=, go from the highest band down. (With <, go from the lowest up: =IF(B2<50, "F", IF(B2<65, "C", …)).)
Count the brackets
Every IF opens a bracket, and they all close at the end: three IFs need ))). Excel colors matching brackets while you type, which helps.
When there are many bands
Past three or four levels, nested IFs get hard to read. Two other ways do the same job:
=IFS(B2>=80, "A", B2>=65, "B", B2>=50, "C", TRUE, "F"), in Excel 2019 and later. The lastTRUEcatches everything else.- A small bands table with VLOOKUP approximate match. The bands live in cells, so you can change them without touching the formula.
Common mistakes
- Lowest band first. The first test catches everyone; start with the highest.
- > instead of >=. "80 or more" includes a score of exactly 80.
- No final answer.
IF(B2>=50, "C")with nothing after it shows FALSE for a score of 47.
FAQ
- How do I write a nested IF in Excel?
- Put the next IF where the FALSE answer goes: =IF(B2>=80,"A",IF(B2>=65,"B",IF(B2>=50,"C","F"))). Close all the brackets at the end.
- Why does my nested IF give everyone the same grade?
- The first test is true for almost everyone, usually because the lowest band is checked first. IF stops at the first true test, so with >= start with the highest band.
- How many IFs can you nest in Excel?
- Up to 64, but a formula with more than three or four is hard to read and check. Use IFS or a lookup table instead.
- Why does my nested IF show FALSE?
- The last IF has no answer for when its test is false. Add a third argument to it, such as "F".