A nested IF gives a grade from a score by testing the conditions in order, one inside another: =IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C",IF(A2>=60,"D","F")))). Paste that into the cell next to the first score, fill it down the column, and every score is graded in one pass. It works because Excel stops at the first condition that is TRUE, which is why the tests must run from highest threshold to lowest. Nothing needs installing — nested IF is built into every version of Excel, Excel for the web and Google Sheets alike, though the exact menu labels can differ slightly by version, device or region.
What You'll Need
- Excel on desktop, Excel for the web, or Google Sheets (the formula works the same in all three).
- A column of numeric scores, one per student, with the numbers stored as real numbers rather than text.
- Your school's grade boundaries written down in advance — the exact cutoffs for A, B, C and so on.
- Commas as separators if your Excel uses English (US) locale; if your system uses semicolons in formulas, use semicolons throughout.
Step-by-Step
- Lay out your data. Put student names in column A and numeric scores in column B, starting at row 2 so row 1 can hold headers. Leave column C free for the grade. Confirm the scores are numbers: if they sit to the left of the cell by default, they are stored as text and every comparison will fail.
- Write the boundaries in a scratch cell or on paper. For example: 90 and above = A, 80–89 = B, 70–79 = C, 60–69 = D, below 60 = F. Getting this order right is the whole trick.
- Type the first test in the grade cell. In C2 enter
=IF(B2>=90,"A",and pause. You are starting the outer IF; the false branch is where the next IF will go. - Nest the second IF as the false value. Continue so the formula reads
=IF(B2>=90,"A",IF(B2>=80,"B",. Each new IF goes in the position that would otherwise hold the plain text result for a failing grade. - Keep nesting down to the last cutoff. The full formula becomes
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C",IF(B2>=60,"D","F")))). The very last IF uses plain text for its false branch because there is nothing left to test — everything below 60 is F. - Close every bracket. Count the IFs (four) and make sure there are four closing brackets at the end. Excel will offer to fix a missing bracket when you press Enter, but only if the rest of the syntax is sound — do not rely on it.
- Press Enter and check the result. With 87 in B2 you should see B. Change B2 temporarily to 59, then 60, then 90 and confirm you get F, D and A. This proves the boundaries behave as intended before you copy anything.
- Fill the formula down the column. Select C2, grab the small square at the bottom-right corner of the cell (the fill handle) and drag down to the last row, or double-click the fill handle to auto-fill to the end of the adjoining data. Relative references mean B2 becomes B3, B4 and so on automatically.
- Handle blank scores. A blank cell counts as zero and will be graded F, which is misleading. Wrap the whole formula:
=IF(B2="","",IF(B2>=90,"A",...)). The first IF catches empty cells and returns an empty string. - Lock the boundaries if you want them flexible. If you would rather store cutoffs in cells (say G2 holds 90, G3 holds 80), replace the numbers with those references and use absolute references like
$G$2so the fill-down does not shift them.
Common Mistakes
- Testing in the wrong order.
=IF(B2>=60,"D",IF(B2>=90,"A",...))returns D for a score of 95, because 95 passes the first test and Excel stops there. Always go highest threshold first when the result improves as the score rises. - Using < instead of >=.
B2>90would put exactly 90 into the B band. Use>=so boundary scores land in the higher grade, matching most grading schemes. - Forgetting the quotes around grade letters.
=IF(B2>=90,A,...)makes Excel look for a named range called A and returns a #NAME? error. Text results always need double quotes. - Leaving out a closing bracket or adding an extra one — Excel rejects the formula with a message about the formula containing an error.
- Copying with a comma-versus-semicolon mismatch. A formula copied from a website that uses semicolons will not parse on a comma-locale machine. Rewrite the separators rather than pasting blindly.
- Scores stored as text. Numbers imported from another system sometimes arrive as text. Select the column, use Data > Text to Columns and finish the wizard to convert them to numbers.
- Grading blanks as F. As noted above, an empty cell equals zero in comparisons, so add the blank check.
Tips
- Press Alt+Enter (Windows) or Option+Return (Mac) inside the formula bar to add line breaks so a long nested IF is readable. It does not change how the formula works.
- Microsoft recommends using IFS for new work where available —
=IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",B2>=60,"D",TRUE,"F")is shorter and easier to check. Nested IF is still worth knowing because it works in older files and in every version. - Beyond three or four levels, a lookup table with VLOOKUP or XLOOKUP against a small table of cutoffs is easier to maintain and to change when boundaries are revised.
- Add plus and minus grades only if your scheme genuinely uses them; each extra band adds another nested IF and another chance for an ordering mistake.
- Keep a copy of the raw scores on a separate sheet before editing, so a fill-down accident cannot destroy the source data.
Troubleshooting
- Result looks wrong for one score. Select the cell and inspect the formula bar; check the test order and each threshold. Bands that overlap or skip a value are the usual cause.
- #NAME? error. Almost always unquoted text in the result, or a mistyped function name. Check quotation marks first.
- #VALUE! error. The score cell contains text that cannot be compared with a number. Clean the data or convert it to numbers.
- Formula shows as text instead of calculating. The cell is formatted as Text, or the formula was typed with a leading apostrophe. Format the cell as General, then re-enter the formula.
- Excel refuses to accept the formula. Bracket count is the first check; then look for a missing comma between an IF's arguments.
- Fill-down produced identical results. Relative references became absolute, or the formula was entered as a single array. Check for stray dollar signs.
Frequently Asked Questions
How many IFs can I nest?
Current Excel allows up to 64 nested functions, but readability collapses long before that. Past three or four levels, switch to IFS or a lookup table.
Why does my formula give the wrong grade at exactly 90?
You are probably using > where you meant >=, so 90 falls into the lower band. Change the operator, not the threshold.
Does nested IF work in Google Sheets?
Yes, the same syntax and the same rules apply, and Sheets also supports IFS.
How do I stop blank rows from being graded F?
Wrap the formula in an outer test: =IF(B2="","",...) returns nothing for empty cells instead of a failing grade.
What if my grade bands change every term?
Put the cutoffs in cells and reference them with absolute addresses, or use a VLOOKUP table. That way you edit four numbers instead of rewriting the formula.
Can I grade on a curve with nested IF?
Only if the bands are fixed numbers. For a curve you would first calculate the adjusted score in its own column, then point the nested IF at that column.