Skip to content

IFERROR

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(, )

Logical

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
A
B
C
D
1
Region
Revenue
Orders
Revenue per order
2
North
48200
0
0
3
South
31750
125
4
5

D2 =IFERROR(B2/C2,0) returns 0

How IFERROR works

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.

The two arguments

  • value is the formula to run. Put the whole calculation here.
  • value_if_error is what to show instead of an error. Text, a number, empty text "" 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.

The risk: hiding real mistakes

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.

Better than IFERROR in many cases

  • Division by zero. =IF(C2=0, 0, B2/C2) states the case you expect, and a different error, such as text in C2, will still show.
  • Lookups. IFNA, or XLOOKUP's fourth argument, covers just the "not found" case.
  • Missing inputs. =IF(B2="", "", ...) leaves a result blank when its input is blank, so you aren't relying on an error to do it.

Where IFERROR is a good fit

  • Quick reports where a blank or zero is acceptable for any failure.
  • Formulas whose errors are harmless and varied, such as parsing text with VALUE or DATEVALUE when some entries are junk.
  • Presentation layers over a calculation sheet that is checked separately. Check the sheet underneath for errors first.

Practical habits

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.

Arguments

value
The formula or reference to check, such as B2/C2 or a lookup. If it returns an error, IFERROR returns value_if_error instead.
value_if_error
What to return if value is an error: text such as "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!.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

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
A
B
C
D
1
Region
Revenue
Orders
Revenue per order
2
North
48200
0
0
3
South
31750
125
4
5

D2 =IFERROR(B2/C2,0) returns 0

Example 2

Show a message when a lookup fails

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
A
B
C
D
1
SKU
Price
2
SKU-101
39
3
SKU-102
89
4
SKU-103
54
5
6
Find
Price
7
SKU-200
Not listed
8

B7 =IFERROR(VLOOKUP(A7,A2:B4,2,FALSE),"Not listed") returns Not listed

Example 3

The danger: IFERROR also hides a typo

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
A
B
C
D
1
SKU
Price
2
SKU-101
39
3
SKU-102
89
4
SKU-103
54
5
6
Find
Price
7
SKU-102
Not listed
8

B7 =IFERROR(VLOKUP(A7,A2:B4,2,FALSE),"Not listed") returns Not listed

Example 4

Clean up unreliable text-to-number conversions

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
A
B
C
D
1
Imported amount
As number
2
1,250
3
n/a
0
4
5

B3 =IFERROR(VALUE(A3),0) returns 0

Your turn.

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.

D2
A
B
C
D
E
F
G
1
Region
Revenue
Orders
Revenue per order
SKU
Price
2
North
48,200
0
SKU-101
39
3
South
31,750
125
SKU-102
89
4
East
42,900
210
SKU-103
54
5
West
37,400
0
6
7
SKU
Price
8
SKU-102
9
10
11

Common mistakes

  • IFERROR catches every error, including #NAME? from a typo and #REF! from a deleted column. A broken formula can look fine. Use IFNA when only #N/A is expected.
  • Returning 0 can make a failed calculation look like a real zero in totals and averages. Consider "" or a visible message instead.
  • Returning "" makes the cell empty text. Arithmetic on it gives #VALUE!, and ISBLANK on it returns FALSE.
  • Wrapping the whole formula hides which part failed. Wrap only the part that is expected to fail.
  • Don't use IFERROR to make a model "clean" before it is checked. Fix the error first, then decide whether a fallback is needed.

Questions people ask

What is the difference between IFERROR and IFNA?

IFERROR replaces every error. IFNA replaces only #N/A. For lookups, IFNA is usually safer, because other errors, which are real mistakes, still show.

Why is IFERROR considered risky?

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.

How do I return a blank instead of an error?

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.

Does IFERROR work in older versions of Excel?

Yes, it has been in Excel since 2007. In Excel 2003 and earlier, use `=IF(ISERROR(formula), fallback, formula)`.

Learn IFERROR in a real sheet.

IFERROR is taught in Logic and text, lesson 5: IFERROR and IFNA. Each lesson is a short, graded exercise like the one above.