Sub topic 12
When IFERROR hides real problems
This chapter assumes you can write IFERROR and IFNA formulas, read the common error values (#N/A, #DIV/0!, #VALUE!, #REF!, #NAME?, #NUM!), and use VLOOKUP with cell references and ranges. It covers how IFERROR can cover up mistakes in your sheet, and how to keep the fallback without losing the warning.
Why IFERROR is risky
An error value is the sheet telling you something is wrong. IFERROR replaces every error with whatever fallback you chose, so a formula that worked yesterday and broke today can look exactly like a formula that is working.
IFERROR does not check which error occurred. A #N/A from a missing lookup key is often an expected result. A #REF! from a deleted column is a bug in your sheet. IFERROR handles both the same way.
=IFERROR(VLOOKUP(A2,Prices!A:B,2,FALSE),"Not found")This formula is useful while the Prices sheet is intact. If someone deletes the Prices sheet or its key column, the lookup returns #REF!. IFERROR catches it, and every row shows "Not found". The report looks like a data problem ("none of these products have prices") when the real problem is a broken formula.
Three ways errors get masked
A fallback that looks like a real answer
The most damaging fallback is 0, because it is a valid number.
=IFERROR(C2/D2,0)Suppose column D holds unit counts. A row with D2 equal to 0 gives #DIV/0!, and returning 0 for it is reasonable. But a row where someone typed the text n/a into D2 gives #VALUE!, and a row whose D2 reference points at a deleted column gives #REF!. All three display 0.
The wrong zeros then flow into other formulas. AVERAGE counts the zeros, so the average is lower than the true value, and nothing in the sheet shows why.
One wrapper around a long formula
When IFERROR wraps a long formula, any error from any part is caught. A wrapper around the whole formula in the next example hides an error in the lookup, the division, or the percent calculation.
=IFERROR(VLOOKUP(A2,Rates!A:B,2,FALSE)*C2/D2,0)If this returns 0, you cannot tell whether the key was missing, the rate was text, or D2 was empty.
A catch-all message in a combined formula
You can wrap IFS in IFERROR to give unmatched scores a message:
=IFERROR(IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C"),"Check score")This is a reasonable pattern, but "Check score" covers every failure: a blank cell, a score below 70, or an error value in B2 that came from an upstream formula. A score of 65 is a valid input with no matching rule, so a TRUE fallback is the cleaner fix for it, and IFERROR can then be limited to real failures.
Which errors each function catches
The table shows what each function handles when it wraps a formula.
| Error value | Typical cause | IFERROR | IFNA |
|---|---|---|---|
| `#N/A` | Lookup key not found | Replaces it | Replaces it |
| `#DIV/0!` | Divisor is 0 or empty | Replaces it | Shows the error |
| `#VALUE!` | Text where a number is needed | Replaces it | Shows the error |
| `#REF!` | Deleted cell, column, or sheet | Replaces it | Shows the error |
| `#NAME?` | Misspelled function or name | Replaces it | Shows the error |
| `#NUM!` | Invalid number, such as a negative square root | Replaces it | Shows the error |
IFNA is the narrower tool. If you only expect "key not found", IFNA lets every other error stay visible:
=IFNA(VLOOKUP(A2,Prices!A:B,2,FALSE),"Not found")Now a deleted Prices sheet produces #REF! in the cells, and you notice it.
Strategies that keep the fallback and the warning
Use the narrowest handler
Use IFNA for lookups, where "not found" is the only expected failure. Use IFERROR only when you have decided that any failure should be replaced, for example a presentation sheet that must not show error values.
Test for the case you expect
For division, check the divisor yourself rather than catching every error.
=IF(D2=0,"No units",C2/D2)Here a zero divisor gets a clear message. If D2 contains the text n/a, D2=0 is FALSE, the division runs, and you see #VALUE!. That is the right outcome, because the text is a data problem you should fix.
To treat blank cells separately from zeros, add a second test:
=IF(D2="","Missing",IF(D2=0,"No units",C2/D2))This pattern also reads as a plain statement of your rules, and anyone can see what you decided to handle.
Guard the input, then run the logic
For the grade formula, check the input first and let IFS handle the ranges. The TRUE fallback covers scores below 70, so the only values that reach the "Check score" message are blank or non-numeric.
=IF(ISNUMBER(B2),IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F"),"Check score")If an unexpected error occurs inside IFS, it is not hidden, because there is no IFERROR around it.
Choose a fallback that stands out
A fallback should be distinguishable from real data. Prefer text such as "Check" or "" over 0 when the column feeds calculations. AVERAGE, SUM, and MIN skip text and empty strings in a range, so they ignore the fallback. A zero would be counted.
| Fallback | Effect on `AVERAGE` of the column | Visible to a reader |
|---|---|---|
| `0` | Counted as a real value, lowers the average | No, looks like data |
| `""` | Skipped | Looks like an empty cell |
| `"Check"` | Skipped | Yes |
Use "" when the cell should look empty. Use visible text when someone needs to follow up.
Count the fallbacks
If you keep a distinctive fallback, you can count how often it appears. Put this in a summary cell:
=COUNTIF(E2:E100,"Check*")A count that jumps from 3 to 100 after you edit the sheet tells you a formula broke. You can also add a conditional formatting rule that colors cells equal to Check.
Inspect the real error while debugging
To find out what an IFERROR is hiding, copy the formula to a scratch cell and remove the wrapper. Or use ERROR.TYPE, which returns a number for each error. In Google Sheets, #DIV/0! is 2 and #N/A is 7.
=ERROR.TYPE(C2/D2)If the cell holds no error, ERROR.TYPE returns #N/A, so it works best for cells you already know are failing. A diagnostic column like this next to the real one is a quick way to audit a sheet.
A decision flow
The diagram shows how to pick a handler for a formula that can fail.
A worked example
A sheet has product codes in column A, quantities in column B, and a price table on a sheet named Prices. You want a total per row.
First version:
=IFERROR(VLOOKUP(A2,Prices!A:B,2,FALSE)*B2,0)This returns 0 for an unknown code, text in the quantity column, a deleted Prices sheet, and a misspelled function. The grand total is wrong and nothing flags it.
Better version:
=IFNA(VLOOKUP(A2,Prices!A:B,2,FALSE)*B2,"Unknown code")An unknown code shows "Unknown code". Text in B2 gives #VALUE!, and a deleted Prices sheet gives #REF!. Both stay visible. A summary cell with =COUNTIF(C2:C100,"Unknown code") tells you how many rows need attention, and SUM skips the text.
Checklist
- Can an
IFtest the known cause? Use it. - Is the only expected failure "not found"? Use IFNA.
- Does a fallback of 0 feed a total or average? Use
""or visible text. - Is the IFERROR wrapping a long formula? Wrap the smallest part that can fail.
- Can you count the fallbacks in a check cell? Add one.
Exercise
The formula =IFERROR(C2/D2,0) is used for a "conversion rate" column, and the column is averaged at the bottom. Someone enters the text n/a in D5. Describe what happens to the average, and rewrite the formula so that a zero divisor shows "No units" while the n/a entry stays visible as an error.
Show answer
Without a fix, C5/D5 returns #VALUE!, IFERROR changes it to 0, and the average counts that 0 as a real conversion rate, so the average is too low with no sign why. A better formula is =IF(D2=0,"No units",C2/D2). A zero divisor gives "No units", which AVERAGE skips. The text n/a makes D2=0 FALSE, so the division runs and shows #VALUE!, which tells you to fix the data.
Exercise
=IFERROR(VLOOKUP(A2,Prices!A:B,2,FALSE),"Not found") shows "Not found" in every row after a coworker deletes the Prices sheet. Why, and which function would have exposed the problem?
Show answer
Deleting the sheet makes the lookup return #REF!, and IFERROR replaces every error type with "Not found". =IFNA(VLOOKUP(A2,Prices!A:B,2,FALSE),"Not found") replaces only #N/A, so #REF! would show in the cells and flag the broken reference.