The IFERROR function
IFERROR runs a formula and, if the result is any error, shows something else instead. It keeps reports tidy when some rows can't be calculated yet: dividing by zero, a lookup that finds nothing, a missing value.
It catches *every* kind of error, which is convenient but can also hide real mistakes. If you only expect #N/A from a lookup, IFNA is the safer choice.
=IFERROR(value, value_if_error)
Arguments
- value
- The formula that might go wrong.
- value_if_error
- What to show instead if it does, such as 0, "" or a message.
Try it
=IFERROR(C3/B3,"No clicks") in D3. Social has no clicks, so C3/B3 would be #DIV/0!. IFERROR shows No clicks instead.
D3
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Campaign | Clicks | Sales | Conversion | |
| 2 | 400 | 18 | |||
| 3 | Social | 0 | 0 | No clicks | |
| 4 | Search | 250 | 20 | ||
| 5 | |||||
| 6 |
Edit the formula in D3, or change the data, and press Enter.
More examples
| Formula | Result | What it does |
|---|---|---|
| =C3/B3 | #DIV/0! | The same sum without IFERROR. |
| =IFERROR(C2/B2,"No clicks") | 4.5% | When there's no error, the normal result comes through. |
| =IFERROR(C4/B4,0) | 8.0% | A number as the fallback, so totals and charts still work. |
| =IFERROR(VLOOKUP("Radio",A2:C4,2,FALSE),"Not listed") | Not listed | Catching the #N/A from a failed lookup. |
Tips
- Use
""as the fallback to leave the cell looking blank. - Build and test the formula first, then add IFERROR. Otherwise it can hide a typo in the formula itself.
- For lookups, prefer IFNA or XLOOKUP's own if_not_found, which only catch "not found".
Common mistakes
- A total is wrong but no error shows.IFERROR hid a real error, such as a #REF! from a deleted column or a #VALUE! from text in a number column. Remove IFERROR briefly to see what's underneath.
- Totals of the column give #VALUE!.The fallback is text, such as "No clicks", and a formula adds the column with +. Use SUM, which skips text, or make the fallback 0.
Practise IFERROR with instant feedback
Type real formulas into a working spreadsheet and get told straight away whether they work.