Sub topic 12
Common mistakes and how to fix them
This chapter assumes you can write an IF formula, use comparison operators, and copy a formula down a column. It covers the errors that show up most often and how to diagnose each one. Most of them come from a handful of habits, so a short checklist will find the cause quickly.
Missing quotes around text
Text in a formula must be inside double quotes. Without quotes, Excel reads the word as a name and returns #NAME?.
=IF(A2=Yes,"Approved","Pending")Fix it by quoting the text:
=IF(A2="Yes","Approved","Pending")The reverse mistake also happens. Putting quotes around a number turns it into text, so =IF(B2>="60","Pass","Fail") compares a number with text and gives wrong answers. Leave numbers unquoted.
Comparison of text ignores case, so "yes", "Yes", and "YES" all match. If a match fails, look for extra spaces in the cell, such as "Yes ". The TRIM function removes them.
Wrong operator
Two slips are common here.
- Writing
=>instead of>=. Excel rejects=>. The equals sign always comes second. - Using
=when you meant<>. To test "is not equal to", use<>.
Check the boundary value as well. If 60 should pass, use >=60. Using >60 fails a score of exactly 60 without any error message, which makes this mistake easy to miss.
Mis-ordered nested tests
Nested IF stops at the first true test. If you test the lowest threshold first, every higher score matches it and the later tests never run.
=IF(B2>=70,"C",IF(B2>=80,"B",IF(B2>=90,"A","F")))A score of 95 returns "C" here. Test from the highest threshold down:
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C","F")))The same rule applies to IFS, which also returns the result of the first true test.
AND and OR written the wrong way
AND and OR take whole conditions as arguments. They cannot be chained inside a single comparison.
=IF(B2>=60 AND C2>=60,"Pass","Fail")This formula is invalid. Use the function form:
=IF(AND(B2>=60,C2>=60),"Pass","Fail")Likewise, D2="Gold" OR "Platinum" does not work. Repeat the full comparison: OR(D2="Gold",D2="Platinum").
References that shift when copied
If every row compares against one threshold cell, write it as $F$1. With F1, the reference moves down as you copy, and the formula soon points at empty cells. An empty cell counts as 0, so most rows will give the same result.
=IF(B2>=$F$1,"Target met","Below target")Blank cells and errors
A blank cell is not always treated the way you expect. In a numeric comparison it behaves like 0, so =IF(B2<60,"Fail","Pass") marks a blank row as "Fail". Test for blanks first:
=IF(A2="","",B2*C2)For division, test the divisor before dividing:
=IF(C2=0,"",B2/C2)Keep in mind that a cell holding "" from a formula looks blank but contains text. Later numeric formulas that refer to it may produce #VALUE!.
Other things to check
- Parentheses must match. Each
IF(needs its own closing). Excel colors matching pairs as you edit. - Arguments are separated by commas in most English settings. Some regional settings use semicolons.
- Numbers stored as text, often from imported data, fail numeric tests. A small green triangle in the cell is a hint.
- Use Formulas > Evaluate Formula to step through a formula one part at a time.
| Symptom | Likely cause | Fix |
|---|---|---|
| `#NAME?` | Text without quotes | Add double quotes |
| Boundary value gives wrong result | `>` instead of `>=` | Use the correct operator |
| Everything returns the same grade | Nested tests in the wrong order | Test highest threshold first |
| Results change oddly down a column | Relative threshold reference | Use `$F$1` |
| Blank rows show "Fail" | Blank counts as 0 | Test `A2=""` first |
Exercise
This formula is meant to give "High" for sales of 1000 or more, "Medium" for 500 to 999, and "Low" otherwise. It returns "Medium" for 1200. Find the cause and write the corrected formula: =IF(B2>=500,"Medium",IF(B2>=1000,"High","Low"))
Show answer
The 500 test comes first, so 1200 matches it and the 1000 test never runs. Test the highest threshold first: =IF(B2>=1000,"High",IF(B2>=500,"Medium","Low"))
Exercise
A formula copied down column C compares each score in B with the threshold in F1. Row 2 works, but row 3 and below give odd results. The formula is =IF(B2>=F1,"Met","Not met"). What is the fix?
Show answer
F1 is a relative reference and shifts to F2, F3, and so on. Change it to $F$1: =IF(B2>=$F$1,"Met","Not met")