IFERROR in Excel: The Protective Clause | 5 Examples + Cheat Sheet | Sheets & Cells
Function · Logical

IFERROR — The Protective Clause

The natural companion to IF. Where IF checks a condition you write, IFERROR checks whether a formula produced an error and swaps it for your fallback. Catches all 7 Excel error types. The single most important function for building resilient dashboards, lookup-heavy sheets, and any workbook you'll share with humans.

Universal support since Excel 2007
Works identically in Excel 365, 2021, 2019, 2016, 2013, 2010, 2007, Excel for the web, Google Sheets, LibreOffice, Apple Numbers. Catches ALL 7 Excel error types: DIV/0, VALUE, REF, NAME, N/A, NULL, NUM. For Excel 2003 and earlier, use the legacy IF+ISERROR combo shown below.
⚠️
The bug swallower problem
IFERROR hides EVERY error — including bugs you'd want to know about. If your formula gets a REF error because you deleted a row, IFERROR silently returns your fallback instead of flagging the problem. Use IFERROR for expected errors (missing lookup, zero denominator, optional cell). Never as a catch-all bug hider. When in doubt, wrap the specific inner formula, not the whole expression — or prefer IFNA which only catches the "not found" case.
Quick answer
IFERROR runs a formula. If it evaluates cleanly, IFERROR returns the result. If it produces an error, IFERROR returns your fallback value instead. Two arguments: the formula that might break, and the value to return if it does.
Syntax
=IFERROR(value, value_if_error)
Working example
=IFERROR(D2/C2, "—") → If D2/C2 evaluates cleanly, returns the division result. If C2 is 0 (division by zero), returns "—" instead of a DIV/0 error.
📗 Free IFERROR example workbook
9 sheets · same 24-row sales log as the function library · DIV/0 wrap · VLOOKUP fallback · cascade chains · IFERROR vs IFNA matrix · 7 error types reference · legacy pattern · 10-pattern cheat sheet
Download .xlsx (free) Open in Sheets
Category
Logical
Difficulty
Beginner
Excel version
2007+
Errors caught
All 7
7
Error types caught
2007
Introduced in Excel
Faster than IF+ISERROR
8/10
Templates using it

Syntax breakdown

IFERROR takes just two arguments. Both are required.

ArgumentTypeWhat it does
value REQUIRED The formula or expression to try. Anything that might error: a division, a lookup, a math operation, a nested calculation. IFERROR evaluates this first.
value_if_error REQUIRED What to return if value produced ANY of the 7 error types. Text (in quotes), number, cell reference, or another formula — including another IFERROR for cascading.
Evaluation order: IFERROR always tries value first. Only if value returns an error does IFERROR evaluate value_if_error. This is short-circuit behavior — critical when your fallback is itself expensive (like another lookup).

Five working examples

Every example uses the same 24-row sales log as the IF and IFS family pages. Same Q1 2026 data, plus supplementary tables for quota and product-code demonstrations.

01 DIV/0 guard — the classic use case

Commission attainment = sales ÷ quota. Some quotas are $0 (new reps, unassigned territories). Division breaks. IFERROR fixes it.

=IFERROR(D2/C2, "—")
Runs the division, catches any error, substitutes "—" when quota is 0
SalespersonQuotaSalesNaive: =D/CIFERROR wrapped
Emma Thompson$50,000$26,319.6052.6%52.6%
David Kim$0$28,749.40DIV/0 error
Sofia Rodriguez$40,000$7,749.5019.4%19.4%
Michael Chen$45,000$32,649.5572.6%72.6%
Aisha Patel$30,000$16,179.3553.9%53.9%
James Wilson$0$21,024.75DIV/0 error

The wrapped column stays clean — a mix of percentages and "—" that a dashboard can render, a SUM can skip, and a human can read. The naive column breaks any downstream aggregation that touches it.

02 VLOOKUP fallback — turn N/A into a message

When a lookup fails, VLOOKUP returns #N/A. IFERROR turns that into text users can understand.

Simple fallback

=IFERROR(VLOOKUP(B2, ProductMaster, 2, FALSE), "Unknown code")
Returns the product name if found; "Unknown code" if not

Formatted fallback (helps the operator)

=IFERROR(VLOOKUP(B2, ProductMaster, 2, FALSE), "Code "&B2&" — please add to master")
Injects the missing code into the message: "Code W-C — please add to master"
CodeQtyNaive VLOOKUPIFERROR wrapped
W-A12Widget AWidget A
G-P5Gizmo ProGizmo Pro
W-C8N/A errorUnknown code
B-X3Bundle XBundle X
G-Z15N/A errorUnknown code
Why wrapping is critical here: an N/A error propagates. Any downstream SUMIF, COUNTIF, or reference that touches the N/A cell will ALSO error. Wrapping VLOOKUP keeps the value cell "clean" (text or number), so aggregations and dashboards stay working.

03 Cascade chain — try this, then that, then default

Nested IFERROR lets you try multiple lookup strategies in order, falling through until one works. The killer use case.

=IFERROR(VLOOKUP(A2, T1, 2, 0), IFERROR(VLOOKUP(A2, T2, 2, 0), "Not found"))

Reads: try table 1. If that errors, try table 2. If THAT errors, return "Not found". Progressive fallback through as many strategies as you need.

Common real-world cascades:

  • Cache → main → default. Local cache table first (fastest), main table second (authoritative), text default last.
  • Current year → prior year → default. Lookup this year's data first; if missing, use last year's; if that's missing, "N/A".
  • Exact match → approximate match → default. Try VLOOKUP(...,FALSE); if that fails, VLOOKUP(...,TRUE); if that fails, default.

The cascade pattern, visualized

Nested IFERROR is the pattern most beginners struggle with. Here's exactly how Excel reads a 2-level cascade — one attempt at a time, falling through on error:

How Excel reads the cascade

=IFERROR(VLOOKUP(code, PrimaryTable, ...), IFERROR(VLOOKUP(code, BackupTable, ...), "Not found"))
Attempt #1: VLOOKUP in Primary Table → SUCCESS Return value
ERROR — code not in primary
Attempt #2: VLOOKUP in Backup Table → SUCCESS Return value
ERROR — code in neither table
All attempts failed → FALLBACK "Not found"
The mental model: think of it as an OR chain where each attempt is progressively less desirable. Excel takes the first attempt that succeeds and stops. If none succeed, the final fallback catches everything. A hit on the primary table never sees the backup call — this is the short-circuit benefit that makes cascades cheap even at scale.

04 IFERROR vs IFNA — which one to use?

Excel 2013 added IFNA, a stricter cousin of IFERROR that catches ONLY the N/A error. Sometimes stricter is better.

The problem with IFERROR: it catches everything, including bugs. If you delete a row and a formula gets a REF error, IFERROR silently swaps in your fallback. You never learn the reference is broken.

What IFNA does differently: it catches ONLY N/A — the "not found" outcome. If your formula produces any OTHER error, IFNA lets it surface. Perfect for lookup-heavy work where "not found" is the only expected failure.

=IFNA(VLOOKUP(A2, tbl, 2, FALSE), "Not found") // If VLOOKUP returns N/A → "Not found". If it returns REF/VALUE/NAME → the error surfaces (as it should).

The 7 Excel error types, side-by-side

Excel has exactly 7 error types. Here's what each one means, what causes it, whether IFERROR/IFNA/ISERROR catch it, and whether wrapping is even the right response:

Error What it means Wrap it? IFERROR IFNA ISERROR
#DIV/0! Division by zero Yes, when 0 is possible
#VALUE! Wrong data type No — usually a bug
#REF! Broken reference No — always a bug
#NAME? Unknown function or range No — always a bug
#N/A Lookup found no match YES — the main case
#NULL! Empty range intersection No — always a bug
#NUM! Invalid number (sqrt of negative, non-convergent IRR) Yes, for optional calcs
The takeaway: only 3 of the 7 errors are legitimate wrap targets — DIV/0 (when zero denominators are possible), N/A (the main lookup case), and NUM (for calculations that might not converge). The other 4 — VALUE, REF, NAME, NULL — are almost always bugs. Wrapping them hides the bug; fixing them makes the workbook correct. Use IFERROR sparingly. Use IFNA whenever "not found" is your only expected failure.

IFERROR vs IFNA vs ISERROR — a three-way comparison

Three functions in the "check for errors" family. Same problem, different tools. When to reach for which:

Aspect IFERROR IFNA ISERROR
Introduced Excel 2007 Excel 2013 Excel 1.0
Catches All 7 errors N/A only All 7 (returns TRUE/FALSE)
Returns Value or fallback Value or fallback TRUE or FALSE
Evaluates value... Once Once Once (with IF: twice)
Typical use Wrap fragile calc, keep math clean Wrap VLOOKUP, let bugs surface Legacy Excel 2003 pattern
Best for Multi-cause failures Lookup-only work Legacy or when you need TRUE/FALSE
Practical rule: reach for IFNA first when you're wrapping a lookup. Fall back to IFERROR when the formula might legitimately fail in multiple ways. Only use IF+ISERROR when you need Excel 2003 compatibility OR when the error path needs different logic than the success path.

Interactive playground

Try it Live IFERROR demonstration

Mirrors live cells from the workbook. Edit the yellow input, watch the blue result update.

Input · Quota
$0
Output · Attainment
=IFERROR(D2/C2, "—")
Input · Product Code
W-C (not in table)
Output · Product Name
Unknown code
=IFERROR(VLOOKUP(A2, ProductMaster, 2, FALSE), "Unknown code")

Download the workbook to try the cascade sheet and IFERROR vs IFNA comparison live.

The IFERROR cheat sheet — 10 patterns for daily use

Copy any of these, adapt the ranges to your data, and you're covered for the most common IFERROR scenarios:

10 patterns you'll use every day

From basic DIV/0 guards to cascades and IFNA alternatives. Every one is a copy-paste starting point.

1DIV/0 guard (→ 0)
=IFERROR(A2/B2, 0)
Return 0 when denominator is zero. Number-safe fallback for aggregations.
2DIV/0 guard (→ text)
=IFERROR(A2/B2, "N/A")
Text fallback — clearer for humans but breaks downstream math.
3VLOOKUP fallback
=IFERROR(VLOOKUP(A2,tbl,2,0), "Not found")
The lookup classic. Turns N/A into a readable message.
4VLOOKUP → 0
=IFERROR(VLOOKUP(A2,tbl,2,0), 0)
For aggregations that need numbers, fallback to 0.
5Cascade (2 lookups)
=IFERROR(VLOOKUP(A2,T1,2,0), IFERROR(VLOOKUP(A2,T2,2,0),"—"))
Try table 1, then table 2, then default. Progressive fallback.
6XLOOKUP built-in
=XLOOKUP(A2,keys,vals,"Not found")
XLOOKUP has fallback built in — no IFERROR wrap needed.
7Concat with fallback
=IFERROR("Match: "&VLOOKUP(A2,tbl,2,0), "No match")
Format the found value with a prefix; different text on error.
8INDEX/MATCH wrap
=IFERROR(INDEX(tbl,MATCH(A2,keys,0),2), "—")
Same pattern as VLOOKUP, works with INDEX/MATCH.
9IFERROR + SUMIFS
=IFERROR(SUMIFS(A,B,"X")/COUNTIFS(B,"X"), 0)
Manual average — protect from divide-by-zero when no matches.
10Prefer IFNA
=IFNA(VLOOKUP(A2,tbl,2,0), "Not found")
IFNA only catches N/A — REF/VALUE bugs still surface.

Common IFERROR pitfalls

IFERROR itself rarely errors — but the way people use it does. Six scenarios to avoid:

ProblemWhy it happensBroken → Fix
Bug swallower Wrapped too much — an inner REF bug looks like "Not found." =IFERROR(SUM(A:A)/VLOOKUP(...), 0) =SUM(A:A)/IFERROR(VLOOKUP(...), 1) // wrap only the fragile part
Silent 0 Fallback of 0 makes empty matches look like real zeros in aggregations. =IFERROR(VLOOKUP(...), 0) // sums include phantom zeros =IFERROR(VLOOKUP(...), "") // blank instead — safer for aggregations
Wrong function Used IFERROR when only N/A was expected — hid a legitimate REF bug. =IFERROR(VLOOKUP(...), "Not found") =IFNA(VLOOKUP(...), "Not found") // lets REF/VALUE surface
Missing 2nd arg IFERROR needs BOTH arguments. Excel doesn't accept a one-arg version. =IFERROR(VLOOKUP(...)) // returns TRUE/FALSE (wrong) =IFERROR(VLOOKUP(...), "") // always give the fallback
Legacy pattern Still using IF+ISERROR out of habit. Evaluates the formula twice. =IF(ISERROR(D/C), "—", D/C) // D/C runs twice =IFERROR(D/C, "—") // D/C runs once
Wrapped constant IFERROR around a value that can't error. Just dead code. =IFERROR("Hello", "fallback") // never errors ="Hello" // remove the wrapper
📗 Every example above, in one workbook
DIV/0 wrap · VLOOKUP fallback · Cascade chains · IFERROR vs IFNA matrix · 7 error types reference · Legacy pattern · Cheat sheet.
Download iferror-examples-2026.xlsx

IFERROR is IF, specialized for errors

🔗 The relationship with IF
IF takes a boolean condition you write (A2>100) and picks one of two branches. IFERROR takes a formula and picks the value OR the fallback based on whether the formula errored. Both are conditional; IFERROR just automates the "did this thing break?" check. Legacy Excel used =IF(ISERROR(x), fallback, x) — literally IF + a "did it error" boolean. IFERROR compressed that pattern into one function and evaluates the inner formula only once.

Companion functions worth knowing

Natural wrap targets — functions IFERROR commonly guards

Excel version compatibility

IFERROR shipped in Excel 2007. For older versions, use the IF+ISERROR pattern:

PlatformSupports IFERROR?Notes
Excel 365 (Windows & Mac)✓ YesFull support
Excel 2021 / 2019 / 2016 / 2013 / 2010 / 2007✓ YesFull support
Excel 2003 and earlier✗ NoUse IF+ISERROR pattern
Excel for the web✓ YesFull support
Excel on iPad & iPhone✓ YesFull support
Google Sheets✓ YesSame syntax
LibreOffice Calc✓ YesFull support
Apple Numbers✓ YesFull support

When to use IFERROR vs. alternatives

Use IFERROR when…

  • Multiple error types are expected. A formula that could DIV/0 AND miss a lookup.
  • You want compact syntax. Cleaner than IF+ISERROR.
  • Cross-version compatibility matters. Works in Excel 2007+ everywhere.

Use IFNA instead when…

  • You're wrapping a VLOOKUP, XLOOKUP, MATCH, or INDEX/MATCH.
  • The ONLY expected failure is "not found."
  • You want other bugs (REF, VALUE, NAME) to surface as they should.

Use XLOOKUP's built-in fallback instead when…

  • You're on Excel 365 or 2021 and using XLOOKUP anyway.
  • The 4th argument of XLOOKUP is a native "if not found" — no wrap needed.

Use IF+ISERROR (legacy) when…

  • You must support Excel 2003 or earlier.
  • The success and error branches need genuinely different logic (like multiplying success by 2, or logging errors somewhere).

Don't wrap at all when…

  • The error indicates a real bug (REF, VALUE, NAME) — fix the bug instead.
  • The formula can't produce an error (wrapping a constant is pointless).

How IFERROR actually works

The algorithm

IFERROR evaluates the first argument. If the result is any of the 7 error values (#DIV/0!, #VALUE!, #REF!, #NAME?, #N/A, #NULL!, #NUM!), IFERROR discards it and evaluates the second argument instead. Otherwise, it returns the first argument's value.

Short-circuit evaluation

The second argument is only evaluated if the first errors. This matters when the fallback is expensive — like another VLOOKUP or a complex calculation. In a cascade like IFERROR(A, IFERROR(B, C)), C is only computed when both A and B fail.

The value once — vs the legacy pattern

IFERROR evaluates value exactly once. The legacy IF(ISERROR(x), fallback, x) pattern evaluates x twice — once for the ISERROR check, once for the return value. For complex formulas (large VLOOKUPs, nested SUMIFS), this doubles the calculation cost. IFERROR is measurably faster on real workbooks.

What "error" means to IFERROR

  • Excel errors: the 7 hash-prefixed values are all caught.
  • Empty cells: NOT errors. IFERROR passes empty results through.
  • Zero: NOT an error. Only DIV/0 is; a legitimate 0 result is returned as-is.
  • Text where number expected: depends — some functions coerce, some return VALUE.

Performance notes

IFERROR is fast — comparable to any two-argument function. Two considerations:

  • Deep cascades. Nested IFERROR calls compound. A 5-level cascade is 5 potential formula evaluations, though short-circuit keeps most cases at 1-2.
  • Volatile fallbacks. If your fallback is NOW() or TODAY(), the whole IFERROR becomes volatile-triggered, recomputing on every recalc. Prefer static fallbacks or reference cells that hold volatile values.

Faster than the legacy pattern

IFERROR runs the inner formula ONCE. IF+ISERROR runs it TWICE. On a workbook with 100,000 IFERROR-wrapped VLOOKUPs, that's a real difference — often 30-40% faster recalc times when migrating from IF+ISERROR.

How to write an IFERROR from scratch

  1. Identify the fragile formula

    Ask: "What could break here?" Division by an empty cell, a VLOOKUP against a table that might not contain the key, a SUM over cells that might be text.

  2. Wrap it as the first argument

    Copy the fragile formula into =IFERROR(...). Nothing else changes about the formula itself.

  3. Choose your fallback deliberately

    Number for aggregations, text for display, empty string for "act blank." Not a random value — pick one that makes sense downstream.

  4. Prefer IFNA if it's a lookup

    If N/A is the only expected failure, use IFNA. This is often the right call — you WANT to know if you get a REF error.

  5. Chain for cascades, not for safety

    Nested IFERROR is for progressive fallback (try this, then that). It's NOT for wrapping "just in case" — that path leads to bug-swallowing.

Functions used with IFERROR

🎁 Grab the free IFERROR workbook
9 sheets covering everything on this page — DIV/0 wrap, VLOOKUP fallback, cascade chains, IFERROR vs IFNA matrix, 7 error types, legacy pattern, cheat sheet.
Download iferror-examples-2026.xlsx

Frequently asked questions

What errors does IFERROR catch?

All 7 Excel error types: #DIV/0!, #VALUE!, #REF!, #NAME?, #N/A, #NULL!, and #NUM!. If you want to catch ONLY N/A (leaving other bugs visible), use IFNA instead.

What's the difference between IFERROR and IFNA?

IFERROR catches all 7 error types. IFNA catches only #N/A. IFNA is stricter and preferred for lookup-heavy work because it lets other bugs (REF, VALUE, NAME) surface as they should. IFNA shipped in Excel 2013; older versions must use IFERROR.

Why is my IFERROR returning the wrong value?

Almost always because it's swallowing a bug you didn't mean to catch. Delete a row, get a REF error, IFERROR silently returns your fallback. Debug by temporarily removing the IFERROR wrap to see the underlying error, then decide whether to fix it or wrap it deliberately.

Does IFERROR work in Google Sheets?

Yes, identically. Google Sheets, LibreOffice, and Apple Numbers all implement IFERROR with the same syntax and semantics as Excel.

Can I nest IFERROR statements?

Yes — that's the cascade pattern. =IFERROR(A, IFERROR(B, C)) tries A, falls back to B, falls back to C. Common for progressive lookups: try local cache, then main table, then default text.

Should I always wrap VLOOKUP in IFERROR?

Not always. If missing values are expected (partner data, optional lookups), yes. If VLOOKUP failing means your data is corrupted, no — let it error so you SEE the corruption. For most cases, prefer IFNA over IFERROR when wrapping lookups.

Is IFERROR faster than IF+ISERROR?

Yes, typically 2x faster. IFERROR evaluates the inner formula once. IF+ISERROR evaluates it twice — once for the ISERROR check, once for the return value. On heavy workbooks (10,000+ IFERROR wraps), this compounds to significant recalc time savings.

Does IFERROR require both arguments?

Yes. Both value and value_if_error are required. Excel does NOT accept a one-argument version. If you want "return value or empty string on error," use =IFERROR(formula, "").

How do I catch only some errors and not others?

Use ERROR.TYPE with IF: =IF(ERROR.TYPE(A2)=2, "DIV/0 caught", A2). ERROR.TYPE returns 1-7 for each error type (or #N/A if there's no error). Rarely needed — IFNA usually handles the "just this one" case.

Can IFERROR return a formula instead of a value?

Yes — the second argument can be a formula, cell reference, or another function call. That's how cascade chains work. Just be aware the fallback formula ONLY runs when the first argument errors.

What's the difference between IFERROR and XLOOKUP's fallback argument?

XLOOKUP has "if not found" as its 4th argument — a built-in fallback that avoids needing IFERROR at all. =XLOOKUP(A2, keys, vals, "Not found") is cleaner than =IFERROR(XLOOKUP(...), "Not found"). Prefer the built-in when using XLOOKUP.

Which templates use IFERROR?

Most templates that involve lookups. Invoice (customer lookup), Sales Dashboard (product master), KPI Dashboard (ratio calculations that could divide by zero), Budget Tracker (category totals), Expense Report, Loan Calculator, Inventory Tracker (SKU lookup), and Project Timeline (task-to-owner lookup) all use IFERROR to keep the display clean when inputs are missing.

Templates that use IFERROR

8 of our 10 templates use IFERROR — anywhere lookups or ratios might fail on missing data:

Skip the syntax. Ask in plain English.

The Sheets & Cells AI Add-in writes IFERROR wraps, IFNA guards, and cascade chains — right inside Excel. Type "wrap this VLOOKUP so missing codes show 'not in master'" and get the working formula, ready to paste.

Try the AI Add-in →