Replace errors with IFERROR

Decisions with IF · About 4 minutes

Replace errors with IFERROR

Some formulas can't always be worked out. Dividing by 0 gives #DIV/0!, which looks broken in a report.

IFERROR has two parts: the formula to try, then what to show if it gives an error. =IFERROR(B4/C4,0) reads as "divide B4 by C4; if that's an error, show 0".

When the formula works, IFERROR shows its normal answer. Only errors are replaced. Use it for errors you expect, like a 0 you divide by, not to hide a formula that needs fixing.

Part of Plus

Free during our founding launch: sign in to unlock this lesson's exercises, the timed practice sets and the rest of Plus. The free lessons stay free, with no account needed.

What IFERROR does

IFERROR tries a formula and, if the formula gives an error, shows something else instead: a 0, a blank or a short message. When the formula works, you see its normal answer.

It keeps reports tidy. A divide by 0, or a lookup that finds nothing (#N/A), no longer fills the page with error codes that look broken.

How to write IFERROR

=IFERROR(value, value_if_error)

value
The formula to try, like B2/C2 or a VLOOKUP.
value_if_error
What to show if that formula gives any error. Text goes in quotes, and "" shows a blank cell.

IFERROR worked example

Each shed records its harvest and the crates it filled. In D2 to D4, work out the kg per crate, or show None yet.

Each shed records its harvest and the crates it filled. In D2 to D4, work out the kg per crate, or show None yet.
ABCD
1ShedKgCratesPer crate
2North240830
3South00None yet
4East150625
D2=IFERROR(B2/C2,"None yet")Divide the kg in B2 by the crates in C2; if that can't be worked out, show None yet. North gives 30, South has 0 crates so it shows None yet, and East gives 25.

Common IFERROR mistakes

A real problem is hidden

IFERROR replaces every error, including ones from a typo or a missing cell. Check the formula works on its own first, then wrap it in IFERROR.

The error still shows

Wrap the whole calculation. =IFERROR(B3,0)/C3 only protects B3, so the divide still fails. Put the whole division inside: =IFERROR(B3/C3,0).

IFERROR or IFNA?

Use IFNA after a lookup like VLOOKUP when the only error you expect is #N/A, meaning "not found". Any other error still shows, so a broken formula doesn't get hidden. IFNA is in Excel 2013 and later and in Google Sheets.

Use IFERROR when any error should get the same fallback, like a divide by 0 in a rate column. It works in Excel 2007 and later and in Google Sheets.

Questions people ask

How do I make IFERROR return a blank?

Use two double quotes as the second part: =IFERROR(B2/C2,"").

How do I get rid of #DIV/0! in Excel?

Wrap the division: =IFERROR(B2/C2,0) shows 0 instead. Also check why the cell you divide by is empty or zero.

What's the difference between IFERROR and IFNA?

IFERROR catches every error type. IFNA catches only #N/A, so typos and other mistakes still show.

Can I use IFERROR with VLOOKUP?

Yes: =IFERROR(VLOOKUP(E2,A2:C50,3,FALSE),"Not found"). With XLOOKUP, use its own not-found part instead.

Does IFERROR work in Google Sheets?

Yes. In Sheets you can leave out the second part, and errors then show as a blank cell.

Theme