Example 1
Divide safely
D2 =IFERROR(B2/C2,0)
Result: 0
North has no orders, so B2/C2 would be #DIV/0!. IFERROR returns 0 instead. In D3 the division works and IFERROR passes the result through.
D2 =IFERROR(B2/C2,0) returns 0
Returns a value you choose when a formula produces any error, and the formula's own result otherwise. Handy, but it hides mistakes as well as expected errors.
Syntax
=IFERROR(, )
Excel 2007 and later, including Microsoft 365, Excel 2024, 2021, 2019 and 2016, Excel for the web and the mobile apps.
Try it
Edit the formula in D2 or change the inputs. The sheet recalculates as you type.
D2 =IFERROR(B2/C2,0) returns 0
IFERROR wraps a formula and replaces any error it produces with a value of your choice. =IFERROR(B2/C2, 0) returns the division when it works and 0 when it would have produced #DIV/0!. If there is no error, IFERROR returns the formula's own result untouched.
"" or another formula are all fine.IFERROR doesn't discriminate. It catches every error: #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME? and #NULL!. That is its strength and its weakness.
An error is a warning. If you wrap a lookup in IFERROR and later mistype the function name, delete a referenced column or point at the wrong range, the formula quietly returns your fallback value and the workbook looks fine. A sheet full of "Not found" messages, or zeros that should be real figures, can sit unnoticed for months.
Use IFERROR when you know which error you expect and any other error isn't a worry. If the only expected error is "no match", use IFNA, which catches #N/A only and lets #REF!, #NAME? and the others show. For lookups, XLOOKUP has its own if_not_found argument and doesn't need either wrapper.
=IF(C2=0, 0, B2/C2) states the case you expect, and a different error, such as text in C2, will still show.=IF(B2="", "", ...) leaves a result blank when its input is blank, so you aren't relying on an error to do it.Keep the fallback visible during building. Use a message such as "CHECK" instead of "", so errors show up when you test. Count what IFERROR is hiding with =SUMPRODUCT(--ISERROR(range)) on the unwrapped formula. And never wrap an entire model in IFERROR to make the errors go away; fix their cause.
B2/C2 or a lookup. If it returns an error, IFERROR returns value_if_error instead."Check", a number such as 0, empty text "", or another formula. IFERROR catches every error type, including #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME? and #NULL!.Each example is a live sheet. Change the inputs or the formula and watch the result.
Example 1
D2 =IFERROR(B2/C2,0)
Result: 0
North has no orders, so B2/C2 would be #DIV/0!. IFERROR returns 0 instead. In D3 the division works and IFERROR passes the result through.
D2 =IFERROR(B2/C2,0) returns 0
Example 2
B7 =IFERROR(VLOOKUP(A7,A2:B4,2,FALSE),"Not listed")
Result: Not listed
SKU-200 isn't in the list, so VLOOKUP returns #N/A and IFERROR shows the message.
B7 =IFERROR(VLOOKUP(A7,A2:B4,2,FALSE),"Not listed") returns Not listed
Example 3
B7 =IFERROR(VLOKUP(A7,A2:B4,2,FALSE),"Not listed")
Result: Not listed
SKU-102 is in the list, but the function name is misspelt. The error is #NAME?, and IFERROR turns it into "Not listed". IFNA would have left the #NAME? visible.
B7 =IFERROR(VLOKUP(A7,A2:B4,2,FALSE),"Not listed") returns Not listed
Example 4
B3 =IFERROR(VALUE(A3),0)
Result: 0
VALUE can't convert "n/a", so it returns #VALUE!, and IFERROR substitutes 0. This is a reasonable use: the error is expected, and any bad entry should count as zero.
B3 =IFERROR(VALUE(A3),0) returns 0
Solve it in the sheet. Every answer is checked, with hints if you need them.
Task 1 of 2
In D2, return revenue per order (revenue divided by orders), but show 0 where a region has no orders. Fill down to D5.
Answer in D2, then it fills down to D5.
#NAME? from a typo and #REF! from a deleted column. A broken formula can look fine. Use IFNA when only #N/A is expected.0 can make a failed calculation look like a real zero in totals and averages. Consider "" or a visible message instead."" makes the cell empty text. Arithmetic on it gives #VALUE!, and ISBLANK on it returns FALSE.IFERROR replaces every error. IFNA replaces only #N/A. For lookups, IFNA is usually safer, because other errors, which are real mistakes, still show.
Because it hides errors you didn't expect, such as a typo in a function name or a deleted column, and the workbook looks as if nothing is wrong.
Use empty text as the second argument: `=IFERROR(B2/C2, "")`. The cell looks blank, but it holds empty text, which breaks arithmetic that refers to it.
Yes, it has been in Excel since 2007. In Excel 2003 and earlier, use `=IF(ISERROR(formula), fallback, formula)`.
IFERROR is taught in Logic and text, lesson 5: IFERROR and IFNA. Each lesson is a short, graded exercise like the one above.