LocalExcelTool
Get started

Excel IFERROR function

IFERROR swaps an error for a value you choose, so a report does not fill with #N/A and #DIV/0!. The cost is that it swallows everything — including a misspelled function (#NAME?) or a deleted reference (#REF!) — so it can hide a genuine configuration mistake. When you only care about "not found", IFNA is the sharper tool.

Logic · Available in: Excel 2007 and later

Syntax

IFERROR(value, value_if_error)

What it returns The value itself when it evaluates cleanly; the second argument when any error occurs.

Arguments
valuerequiredThe expression to guard, usually a lookup or a division.
value_if_errorrequiredWhat to return on error: an empty string "", a zero, or a short message.

Examples

Avoid #DIV/0! in a margin column

RevenueCostMargin
1200800
9000
= IFERROR((A2-B2)/A2,"")

→ 0.3333(第二行显示空白)

Row 2 gives (1200-800)/1200 = 0.333. Row 3 has zero cost, which does not break this formula, but a zero revenue would produce #DIV/0! — and that gets replaced by an empty string.

Leave the cell blank when a lookup fails

SKUPrice
A-100349
Z-999
= IFERROR(VLOOKUP("Z-999",A2:B3,2,FALSE),"")

→ (空白)

Z-999 is not in the table, so VLOOKUP returns #N/A and IFERROR turns it into an empty string. Note the side effect: "this record does not exist" now looks exactly like "the formula is wrong".

Common mistakes

  • 1.Wrapping an entire complex formula in it. The day a reference inside is deleted, the error becomes a blank and nobody notices for months.
  • 2.Swallowing errors that should surface. Use it only where a specific error is expected; let the rest fail loudly.
  • 3.Using it to hide an unlocked VLOOKUP range — the error disappears, the answer stays wrong.

How to use it

  1. 1.Click the cell where the result should appear.
  2. 2.Type = then the function name, and press Tab to accept it.
  3. 3.Enter each argument separated by commas; ranges can be dragged with the mouse.
  4. 4.Press Enter. Drag the fill handle down if the same formula applies to more rows.

Frequently asked questions

What is the syntax of IFERROR?

IFERROR(value, value_if_error). What it returns: The value itself when it evaluates cleanly; the second argument when any error occurs.

Which Excel versions support IFERROR?

Excel 2007 and later. It is available in every desktop version unless the note above says otherwise.

Why does IFERROR return an error instead of a value?

Wrapping an entire complex formula in it. The day a reference inside is deleted, the error becomes a blank and nobody notices for months.

Related functions

More in this group

Need to get the data in first?

← All Excel formulas