IFERROR in Excel: Catch #N/A, #DIV/0! and #VALUE! Before Anyone Sees Them

Source: IFERROR function — Microsoft Support
An Excel error is not a failure; it is the spreadsheet telling you something. #DIV/0! means a denominator is empty. #N/A means a lookup found nothing. The problem is not the error itself but what it does next: it poisons every formula that touches the cell, and it makes a report look broken to anyone who opens it. IFERROR is the function that stands between an honest error and a confused reader, but it has to be used in the right order: fix the cause first, then wrap what remains.
This guide covers what IFERROR catches, how to apply it to real rows, its quieter sibling IFNA, and the one habit that turns IFERROR from a fix into a hiding place.
The syntax, in plain terms
=IFERROR(value, value_if_error) runs the first argument. If it returns any error, Excel shows the second argument instead. The second argument can be a number like 0, empty quotes "" for a blank cell, or a message like "not found". Pick the substitute the way a reader would want it: a 0 where the cell feeds a total, a blank where the cell is display-only, and text only where words belong, because text in a numeric column breaks sums silently.
A worked example: cost per unit
You divide monthly cost by units sold, row by row: =A2/B2. A product with no sales yet has an empty units cell, and the row shows #DIV/0!. Worse, the total row that averages these results also shows #DIV/0!, because one error infects everything downstream. Wrapping the division, =IFERROR(A2/B2,0), shows 0 for the unsold product and lets the average compute. If a fake zero would distort the average, use =IFERROR(A2/B2,"") instead; AVERAGE ignores blanks but counts zeros, so the choice changes the number, not just the display.
| Error | Usual cause | Right response |
|---|---|---|
| #DIV/0! | Empty or zero denominator | Wrap with a 0 or blank substitute |
| #N/A | Lookup found nothing | Check the data, then wrap if "missing" is legitimate |
| #VALUE! | Text where a number was expected | Fix the input; wrapping hides a real defect |
| #REF! | Deleted row, column or sheet | Fix the reference; never wrap |
| #NAME? | Misspelled function name | Fix the spelling; never wrap |
The full list of what it catches, including the dangerous one
IFERROR catches all seven error values: #DIV/0!, #N/A, #VALUE!, #REF!, #NAME?, #NUM! and #NULL!. Six of those are data problems. The seventh, #NAME?, is different: it means Excel did not recognize a function name, usually because of a typo like =VLOKUP(. If you wrap a formula in IFERROR while it still has a spelling mistake, the typo disappears into your substitute value and you ship a sheet that calculates nothing. This is why the rule is order-dependent: write the bare formula, confirm it returns correct results on known data, and only then wrap it.
IFNA: the scalpel for lookups
When the formula is a lookup, catching everything is usually too much. =IFNA(VLOOKUP(...),"not found") catches only #N/A, so a genuine missing item shows your message while a #REF! from a deleted column still screams. That distinction matters in shared files: you want "this customer is not in the list" to look calm and "someone deleted the price column" to be impossible to miss. Both lookup patterns appear all the time in practice; the underlying functions are covered in the guide to INDEX and MATCH, the lookup that works in both directions.
Combining with IF when the condition is knowable
Sometimes you can avoid the error entirely instead of catching it. =IF(B2=0,"",A2/B2) tests the denominator before dividing. This is clearer to the next person reading the sheet, because it documents the reason for the blank rather than catching whatever goes wrong. The IF function handles these single-condition guards well, including several conditions at once, as shown in the Excel IF function with multiple conditions. Reserve IFERROR for cases you cannot predict, like lookup misses and user-entered data.
The audit habit that keeps IFERROR honest
Once a quarter, strip the wrappers on a copy of your file and look at what surfaces. If nothing does, the wrappers are decoration and the sheet is healthy. If a wall of #N/A appears, your source data drifted and the polite messages were concealing it. Some teams also add a hidden check cell that counts errors under the wrappers, so drift raises a flag without bothering readers. Either way, the principle stands: IFERROR is the last step of building a formula, never the first, and it never replaces finding out why the error happened.
A one-minute check before you ship the sheet
- Did the bare formula return correct results before you wrapped it?
- Does the substitute (0, blank, or text) make sense for anything that sums this column?
- Are you catching #N/A with IFNA where only a lookup miss is expected?
- Any #REF! or #NAME? still unwrapped and impossible to hide?
- Would a quarterly unwrap show a clean sheet?
Used this way, IFERROR is not a carpet to sweep errors under. It is the difference between a spreadsheet that fails loudly in front of your manager and one that fails quietly in front of nobody, while you still know exactly where to look.
If you invoice clients or run a small shop, the ready-made Excel sales invoice template and bookkeeping ledger saves building the file from scratch: Excel invoice and bookkeeping template - a product in our store.
المصدر: Microsoft Support: IFERROR function
What IFERROR hides and what it does not
| Formula | Result when the lookup fails | Do you learn the cause? |
|---|---|---|
| =VLOOKUP(A2,T,2,0) | #N/A | Yes, the cell tells you |
| =IFERROR(VLOOKUP(A2,T,2,0),0) | 0 | No, and 0 may be wrong |
| =IFNA(VLOOKUP(A2,T,2,0),"not found") | not found | Partly, and it still flags the row |
IFNA only catches #N/A, which is the lookup failure. IFERROR catches everything, including a divide by zero or a wrong data type, and turns it into a value that looks normal. For a lookup column, IFNA is the safer default.
A rule that keeps reports honest
Wrap a formula in IFERROR only after you have seen the error once and decided what it means. If you wrap first, the error disappears and the total silently changes. A count of the wrapped cells, next to the total, is the cheap way to keep that visible.
Last updated: 5 December 2026
Comments
Post a Comment