Sub topic 12
Common mistakes and how to fix them
This chapter assumes you can write a basic IF formula, copy it down a column, and use AND, OR, nested IF, IFS, IFERROR, and ARRAYFORMULA at a simple level. It covers the mistakes that appear most often when you combine those pieces, and how to find each one.
Formula mistakes come in two kinds. Some produce an error such as #NAME? or #ERROR!. Sheets tells you something is wrong, and you only have to find where. Others produce a clean-looking but wrong answer, such as a failing student marked "Pass". Those are harder because nothing signals the problem. Most of this chapter deals with the second kind.
A method for finding the problem
Start by deciding which kind of problem you have. Then check the pieces of the formula one at a time, instead of rereading the whole formula and hoping to spot the fault.
The test-in-a-spare-cell step is the most useful habit here. If =IF(B2>=50, "Pass", "Fail") gives the wrong answer, type =B2>=50 in an empty cell. If that shows FALSE when you expected TRUE, the problem is in the test, not in the IF.
Errors that Sheets reports
Unquoted text gives #NAME?
Text in a formula must be inside straight double quotes. Without them, Sheets reads the word as the name of a function or range.
=IF(A2=Paid, "Done", "Follow up")This returns #NAME? because Paid is not a defined name. The fix is to quote it:
=IF(A2="Paid", "Done", "Follow up")The reverse mistake is quoting something that should not be quoted. In =IF(B2>="50", "Pass", "Fail"), the "50" is text, not a number. It is also a data-type problem, covered below.
Parentheses and separators give #ERROR!
Every opening parenthesis needs a closing one, and each argument must be separated correctly. Sheets often adds a missing final parenthesis when you press Enter. That can hide a real mistake, because it closes the formula where the end of the text is, not where you meant it to end.
=IF(AND(B2>=50, C2>=50, "Pass", "Fail")Here AND is never closed. Sheets may close the formula at the end, so AND receives four arguments and IF receives only one. The result is wrong or an error. The correct version closes AND after its two tests:
=IF(AND(B2>=50, C2>=50), "Pass", "Fail")When you click into a formula, Sheets highlights each range in a color and highlights matching parentheses. Use this to check which test belongs to which function.
Some locales use a semicolon between arguments instead of a comma, because the comma is the decimal mark. If a formula copied from a tutorial gives a parse error, check File > Settings > Locale. In those locales you write =IF(B2>=50; "Pass"; "Fail").
Smart quotes give #ERROR!
Text pasted from a word processor or a web page often contains curly quotes (“ ”). Sheets only accepts straight quotes ("). The formula looks right but fails to parse. Retype the quotes by hand.
Quick reference for error values
| Error | Typical cause in an IF formula | Fix |
|---|---|---|
| `#NAME?` | Text without quotes, or a misspelled function name | Add straight quotes, check spelling |
| `#ERROR!` | Unbalanced parentheses, wrong separator, curly quotes | Rebalance, check locale, retype quotes |
| `#VALUE!` | Arithmetic on text inside a test or result | Check the cell contents with `ISNUMBER` |
| `#DIV/0!` | A division in the test or result where the divisor is 0 | Test the divisor first, or use `IFERROR` |
| `#N/A` | `IFS` with no matching condition | Add `TRUE, "default"` as the last pair |
| `#REF!` | `ARRAYFORMULA` output blocked by existing data | Clear the cells below the formula |
Wrong results with no error
Text that looks like a number
In Sheets, any text value compares as greater than any number. A cell that holds the text "30", perhaps imported from a CSV file or typed with a leading apostrophe, behaves like this:
=IF(B2>=50, "Pass", "Fail")With a text "30" in B2, the test is TRUE and the result is "Pass". The same happens when B2 contains "absent" or "N/A". Text that is a number is usually left-aligned, while real numbers are right-aligned. To confirm, use =ISNUMBER(B2) in a spare cell.
There are two fixes. You can convert the data (Format > Number > Automatic, then retype the values) or make the formula check first:
=IF(ISNUMBER(B2), IF(B2>=50, "Pass", "Fail"), "Check score")Dates have the same problem. =IF(A2>"2026-01-01", ...) compares against text, so it gives unreliable answers. Compare to a real date with DATE(2026, 1, 1).
Blank cells are treated as zero
An empty cell compares as 0 in numeric tests. So =IF(B2<50, "Fail", "Pass") returns "Fail" for a student with no score yet. If B2 is empty, then B2=0 and B2="" are both TRUE.
The fix is to test for a blank first, as in the earlier chapter:
=IF(B2="", "", IF(B2<50, "Fail", "Pass"))ISBLANK(B2) is stricter than B2="". It returns FALSE for a cell that contains a formula returning "". If the cell you test is itself the output of a formula, use B2="".
Stray spaces
"Paid " with a trailing space is not equal to "Paid". Data pasted from other systems often has these spaces, and you cannot see them. Compare against a trimmed copy:
=IF(TRIM(A2)="Paid", "Done", "Follow up")The same applies to blank checks. A cell holding only a space is not equal to "", but TRIM(A2)="" is TRUE. Use =LEN(A2) to see how many characters a cell really holds.
Text comparison with = is not case-sensitive, so "paid" matches "Paid". The = operator also does not accept wildcards. A2="Pa*" looks for the literal asterisk. For partial matches you need other functions, such as REGEXMATCH.
What you see is not always what is stored
A cell can display a rounded value while storing a more precise one. If B2 holds 49.6 but is formatted with no decimals, it shows 50. The test B2>=50 is still FALSE, because Sheets compares the stored value. Percentages work the same way. A cell showing 50% holds 0.5, so compare with 0.5, not 50. If the display and the result disagree, click the cell and read the value in the formula bar.
References that move when you copy
A threshold written as F1 becomes F2 in the next row, then F3, and so on:
=IF(B2>=F1, "Pass", "Fail")Row 2 works, and row 3 compares with an empty F2, so almost everything passes. Lock the reference with dollar signs:
=IF(B2>=$F$1, "Pass", "Fail")If only the row must stay fixed, F$1 is enough. Copy the formula to a few rows and check that each row points at the cells you expect.
Nested IF tests in the wrong order
IF stops at the first test that is true. If you list the lowest threshold first, every higher score matches it:
=IF(B2>=70, "C", IF(B2>=80, "B", IF(B2>=90, "A", "F")))A score of 95 returns "C" because 95>=70 is checked first. Order the tests from the strictest to the loosest:
=IF(B2>=90, "A", IF(B2>=80, "B", IF(B2>=70, "C", "F")))IFS has the same rule. It also has one more trap: if no condition is true, it returns #N/A. End the list with TRUE, "F" so there is always a match.
The missing third argument
=IF(B2>=50, "Pass") returns FALSE when the test fails. This is not an error, so it is easy to miss in a column of results. If you want an empty cell, write "" as the third argument.
Problems with IFERROR and ARRAYFORMULA
IFERROR hides mistakes
IFERROR replaces every error, not only the one you expected. Take this formula:
=IFERROR(IF(B2/C2>0.5, "High", "Low"), "Check data")It is useful for a zero in C2. It will also show "Check data" if you misspell a function name or break a range. While you are building a formula, leave IFERROR off until the inner formula works. Add it last, and use a message that tells the reader what to check.
AND and OR do not work row by row in an array
Inside ARRAYFORMULA, AND and OR combine the whole range into one answer. They do not give one answer per row. This formula does not do what it appears to do:
=ARRAYFORMULA(IF(AND(B2:B>=50, C2:C>=50), "Pass", "Fail"))It returns one value for the whole column. To get one result per row, multiply the tests. Multiplication acts as AND, and addition acts as OR.
=ARRAYFORMULA(IF(A2:A="", "", IF((B2:B>=50)*(C2:C>=50), "Pass", "Fail")))For OR, use (B2:B>=50)+(C2:C>=50)>0.
An array that cannot expand
An ARRAYFORMULA writes its results into the cells below it. If any of those cells already contains data, Sheets shows #REF! with the message "Array result was not expanded because it would overwrite data". Clear the blocking cell, or remove the old copy-down formulas you no longer need.
A short checklist
- Read the error message by hovering over the cell.
- Copy the test into a spare cell and check that it is
TRUEorFALSEas expected. - Check types with
ISNUMBER,ISTEXT, andLEN. - Check what happens with an empty cell and a cell with only a space.
- Copy the formula to three or four rows and confirm the references.
- Order nested tests from strictest to loosest.
- Add
IFERRORlast.
Exercise
A column of scores is imported from a CSV file. The formula =IF(B2>=50, "Pass", "Fail") returns "Pass" for a score of 20 stored as text. Why does this happen, and how would you change the formula so that text values show "Check score"?
Show answer
Sheets treats any text as greater than any number, so the text "20" passes the test >=50. Check the type first: =IF(ISNUMBER(B2), IF(B2>=50, "Pass", "Fail"), "Check score").
Exercise
The formula =IF(B2>=70, "C", IF(B2>=80, "B", IF(B2>=90, "A", "F"))) returns "C" for a score of 85. Rewrite it so that 85 returns "B", and say what rule you applied.
Show answer
=IF(B2>=90, "A", IF(B2>=80, "B", IF(B2>=70, "C", "F"))). IF stops at the first true test, so list the strictest condition first.
Exercise
You use =IF(A2="", "", "Active") and a row that looks empty still returns "Active". Name one likely cause and a formula that fixes it.
Show answer
The cell probably contains a space or other invisible characters, so it is not equal to "". Use =IF(TRIM(A2)="", "", "Active"). You can confirm the cause with =LEN(A2).