Replace an error with IFERROR
Logic and decisions6 min
Builds on When Excel shows an error.
An office supply store in Massachusetts reports each product's change from last month. Two products are new, so there's no last month to divide by, and their cells show #DIV/0!.
How it works
IFERROR(value, value_if_error) works out the value first. If the result is an error, such as #DIV/0! or #N/A, it returns value_if_error instead. Otherwise it returns the result unchanged.
Picture a safety net under one calculation: anything that falls lands in the net, whatever the reason. A misspelled function name, which gives #NAME?, or a deleted column, which gives #REF!, falls into the same net and shows the same fallback, so a broken formula looks fine. Put the net only under a calculation that can fail for a reason you expect, and choose a fallback that says what happened, such as "New" or "No sales".
IFNA(value, value_if_na) catches only #N/A, the error for a value that can't be found, and lets every other error through. That makes it the safer choice around lookups.
Example
A depot divides its fuel cost in F2 by the deliveries made that day, in G2. On a day with no deliveries, G2 is 0.
=IFERROR(F2/G2,"No deliveries")With $84 of fuel and 12 deliveries it returns 7. On a day with no deliveries, it shows No deliveries.
Common mistakes
=IFERROR(F2/G2,0)on a cost per delivery makes a day without deliveries look free. Show a message, or leave the cell empty-looking with"".=IFERROR(F2/G2,"0")returns the text 0, which SUM skips. Write the number0, without quotation marks.- Wrapping every formula in a report in IFERROR hides real mistakes as well. Wrap only the part that can fail for a reason you expect.
In short
=IFERROR(calculation, what to show instead).- It catches every kind of error, so use it where you know why the error happens.
- A message such as "No sales" tells the reader more than a 0.
IFNAcatches only#N/Aand lets other errors show.
Practice
3 exercises · free with an account