Sub topic 9
When Error Handling Hides Real Problems
This chapter assumes you can enter and copy formulas, use absolute references such as $A$2:$B$100, and write a basic IF and VLOOKUP. It also assumes you know the syntax of IFERROR and IFNA from earlier chapters. Here the focus is on what these functions can hide, and how to keep a workbook honest.
Why error handlers can be dangerous
An Excel error is a signal. #DIV/0!, #REF! and #NAME? tell you that something is wrong with a formula, a reference or the data. IFERROR replaces every one of these signals with the value you chose. The sheet looks clean, but the information that something broke is gone.
Compare two situations:
- A lookup returns
#N/Abecause a new product code is not in the price list yet. This is an expected business case, and a message such as "Not found" is reasonable. - A lookup returns
#REF!because someone asked for column 3 of a two-column table. This is a bug in the formula, and nobody should have to discover it months later.
IFERROR treats both cases the same. IFNA handles only the first.
What each error looks like when it is hidden
The table shows what a wrapped formula conceals for each error type.
| Error | Typical meaning | What `IFERROR` hides |
|---|---|---|
| `#DIV/0!` | Divisor is zero or empty | Missing input data, or a legitimate zero |
| `#N/A` | Value not found | A true miss, or a mismatch in spaces or data types |
| `#VALUE!` | Wrong type of argument | Text where numbers were expected |
| `#REF!` | Reference no longer exists | A deleted column, or a column index beyond the table |
| `#NAME?` | Unknown name or function | A typo in a function or range name |
| `#NUM!` | Invalid number | Impossible arguments, such as the square root of a negative number |
| `#NULL!` | Bad range intersection | A missing colon or comma in a range |
Only #DIV/0! and #N/A are ever expected as part of normal data. The other five almost always point to a formula that needs fixing. IFNA leaves all five visible, and a narrow IF test leaves everything except the one case you named.
Four ways hidden errors go wrong
A typo in a function name
Suppose you type SUMM instead of SUM inside a wrapped formula:
=IFERROR(SUMM(B2:B10), 0)Excel evaluates SUMM as an unknown name, produces #NAME?, and IFERROR turns it into 0. The cell shows a plausible number. Without the wrapper you would see #NAME? immediately and fix the typo.
A wrong column index
This formula looks at a table with two columns but asks for a third:
=IFERROR(VLOOKUP(E2, $A$2:$B$100, 3, FALSE), 0)VLOOKUP returns #REF! because column 3 is outside the table. Every row returns 0. If you wrote the formula with IFNA instead, every row would show #REF!, and you would find the mistake in seconds.
Lookup values that look right but do not match
A product code stored as the number 1001 does not match the text "1001". A code with a trailing space does not match one without. Both produce #N/A, and both look like ordinary missing values:
=IFNA(VLOOKUP(E2, $A$2:$B$100, 2, FALSE), "Not found")IFNA cannot tell a true miss from a data-quality problem. The safeguard here is to make the fallback easy to count (see below), so a sudden jump in "Not found" rows becomes noticeable.
Missing input data treated as a zero result
=IFERROR(A2/B2, 0)If B2 is empty because someone has not yet entered the quantity, the result is 0. A zero looks like a real measurement. The formula cannot distinguish "no data yet" from "the actual result is zero".
How the choice of handler changes what you see
The diagram follows one failing formula through three different designs.
Hidden errors spread into totals
A replacement value does not stay in its own cell. Other formulas use it as real data.
Suppose column C holds =IFERROR(A2/B2, 0) for ten rows, and three rows failed because of missing data. Now compare two summary formulas:
=AVERAGE(C2:C11)The three zeros count as ten-row data, so the average is lower than the true average of the seven valid rows. If the fallback were "" instead, AVERAGE would skip the text and compute across seven values. That result is more accurate, but a different problem appears: a formula such as =C2*2 on an empty-string cell returns #VALUE!.
So the fallback value is a design decision:
| Fallback | `SUM` and `AVERAGE` | Arithmetic such as `=C2*2` | Risk |
|---|---|---|---|
| `0` | Counts it as a real zero | Works | Distorts averages and minimums |
| `""` | Ignores it | Returns `#VALUE!` | Looks blank but is text |
| `"Not found"` | Ignores it | Returns `#VALUE!` | Visible and countable |
| `NA()` | Returns `#N/A` | Returns `#N/A` | Loud, which is useful in charts |
A plain error is sometimes the most honest result. Excel charts, for example, skip #N/A points instead of plotting a false zero.
Narrower alternatives
The aim is to handle the one case you expect and let everything else surface.
Test the cause, not the symptom
If the only expected problem is a zero divisor, test for it:
=IF(B2=0, "", A2/B2)If B2 contains text, this formula still returns #VALUE!, which is correct. Note that an empty B2 evaluates as 0 in this comparison, so empty and zero are handled the same way. If you need them to differ, add a separate test such as IF(B2="", "No data", IF(B2=0, "Zero divisor", A2/B2)).
Use `IFNA` for lookups
=IFNA(VLOOKUP(E2, $A$2:$B$100, 2, FALSE), "Not found")This handles missing values and nothing else. A broken column index, a deleted range or a misspelled function still shows its own error.
Use XLOOKUP's built-in argument
=XLOOKUP(E2, $A$2:$A$100, $B$2:$B$100, "Not found")The if_not_found argument applies only to a missing match. Other problems, such as ranges of different sizes, still produce an error. It has the same selective behavior as IFNA, with one less function to nest.
Check existence separately
=IF(ISNA(MATCH(E2, $A$2:$A$100, 0)), "Missing", "Found")This is useful when you want a status column that is separate from the value column.
Making fallbacks auditable
If you must show a friendly result, make sure someone can still find the problems.
- Use a distinctive fallback text. A message like "Not found" can be counted. A zero or a blank cannot be told apart from valid data.
- Add a check cell near the top of the sheet that counts the fallbacks:
``excel =COUNTIF(F2:F500, "Not found") ``
- Add a second check that counts real errors still in the range:
``excel =SUMPRODUCT(--ISERROR(F2:F500)) ``
- Combine them into a status message that anyone can read:
``excel =IF(SUMPRODUCT(--ISERROR(F2:F500))>0, "Errors present: investigate", "OK") ``
Note that ISERROR here counts the cells that still contain errors. This works only if the range is not wrapped in IFERROR, which is another reason to prefer IFNA.
Also consider whether blank lookup keys should even be looked up. This keeps empty rows from creating false misses:
=IF(E2="", "", IFNA(VLOOKUP(E2, $A$2:$B$100, 2, FALSE), "Not found"))Finding errors that are already hidden
If you inherit a workbook full of IFERROR, try these steps:
- Press
Ctrl+(the grave accent key) to show formulas instead of results, and look forIFERROR` wrapped around large formulas. - Temporarily replace
IFERRORwithIFNA, or remove the wrapper, in one column. Any errors that appear were being hidden. - Use Home, then Find & Select, then Go To Special, then Formulas with only Errors checked. This selects cells that currently show an error, which is a quick way to see how much remains.
- Select a cell showing an error and open Formulas, then Error Checking, then Trace Error, to follow the cause back through precedents.
- Look for suspiciously uniform results such as a whole column of
0. A real data set rarely returns the same value on every row.
Decision guide
| Situation | Preferred approach |
|---|---|
| Lookup value might not exist | `IFNA` or `XLOOKUP` with `if_not_found` |
| Divisor might be zero | `IF(B2=0, ..., A2/B2)` |
| Any error is acceptable and the result is shown only to be read | `IFERROR`, with a counted check elsewhere |
| Result feeds averages or charts | A fallback that does not distort them, such as `""` or `NA()` |
| Formula is new or under development | No wrapper until it is tested |
Exercises
Exercise
A colleague writes =IFERROR(VLOOKUP(E2, $A$2:$B$100, 3, FALSE), "Not found") and every row shows "Not found". What is the actual problem, and how would you change the formula so the problem is visible?
Show answer
The table has only two columns, so a column index of 3 returns #REF!, which IFERROR turns into "Not found". Replace IFERROR with IFNA, which handles only #N/A. Every row then shows #REF!, pointing to the bad column index. Fix the index to 2.
Exercise
Column C contains =IFERROR(A2/B2, 0) for ten rows, and three of the B cells are empty. Explain how AVERAGE(C2:C11) is affected, and write a replacement formula for C2 that keeps the average accurate while only handling the zero-divisor case.
Show answer
The three failed rows contribute 0 to the average, so it is lower than the average of the seven valid rows. Use =IF(B2=0, "", A2/B2). AVERAGE ignores the empty-string text results, so it averages only the seven valid values. Other errors, such as #VALUE! from text in B2, still appear.