How to use IFERROR and IFNA in Excel to handle errors
IFERROR returns a value you choose when a formula results in an error (#N/A, #DIV/0!, #VALUE!). IFNA catches only #N/A. Syntax, examples and pitfalls.
Syntax
=IFERROR(value, value_if_error)
- value — The formula or expression to check for an error, e.g. VLOOKUP(...) or B2/C2.
- value_if_error — What to return on error: text ("Not found"), a number (0) or an empty string ("").
Example
Formula:
=IFERROR(VLOOKUP("P05",A2:C3,3,FALSE),"Not found")→ result: Not found
How IFERROR works
IFERROR first evaluates the first argument. If the result is a normal value, it returns it; if it is an error, it returns the second argument. In the example, code P05 is not in the table, VLOOKUP returns #N/A, and IFERROR shows “Not found” instead. IFERROR does not fix the formula — it only changes how the error looks. Use it where an error is expected: a code that isn’t found, division by zero, rows that aren’t filled in yet.
Excel error types
• #N/A — value not available: typical for VLOOKUP, XLOOKUP and MATCH. • #DIV/0! — division by zero or by an empty cell. • #VALUE! — wrong type of value: adding text to a number, a date stored as text. • #REF! — broken reference: a row or column the formula used was deleted. • #NAME? — a misspelled function name or text without quotes. • #NUM! — invalid number: for example, a start date later than the end date in DATEDIF. IFERROR catches all of them. The first two are usually “normal”, while the others mean something is wrong with the formula itself. (In Russian Excel they appear as #Н/Д, #ДЕЛ/0!, #ЗНАЧ!, #ССЫЛКА!, #ИМЯ? and #ЧИСЛО!.)
With VLOOKUP and XLOOKUP
The most common use is a clean lookup result: =IFERROR(VLOOKUP(F2,$A$2:$C$100,3,FALSE),"Not found") In Excel 365 and 2021, XLOOKUP has its own 4th argument, so IFERROR isn’t needed: =XLOOKUP(F2,A2:A100,C2:C100,"Not found") This is even better: XLOOKUP replaces only the “not found” case, while other errors (such as a broken reference) stay visible.
Getting rid of #DIV/0!
When calculating an average receipt, a percentage or plan completion, the denominator may be 0 or empty: =IFERROR(B2/C2,0) A more precise option is to check the denominator first: =IF(C2=0,0,B2/C2) The second formula only handles division by zero. If B2 accidentally contains text, you’ll see #VALUE! and notice the problem right away.
Return "" or 0?
• "" (empty string) — the cell looks blank and the report looks clean. But it is text: SUM ignores it, yet =D2+1 returns #VALUE!, and COUNTA counts the cell as filled. • 0 — safe for further calculations: totals, averages and charts work correctly. Just remember that AVERAGE includes zeros. • A text message ("Not found", "No code") — clearest for the reader, but you can’t calculate with that column. Rule of thumb: if the result feeds other formulas, return 0; if it’s only for display, return "" or a message.
IFERROR vs IFNA
IFNA (Excel 2013+) catches only #N/A and shows every other error as is: =IFNA(VLOOKUP(F2,A2:C100,3,FALSE),"Not found") Why it matters: if someone deletes a column from the table, VLOOKUP returns #REF!. IFERROR hides that as “Not found” too, and the report becomes silently wrong. With IFNA the real error stays visible. Prefer IFNA in lookup formulas and use IFERROR where the error type doesn’t matter.
Pro tips
• Wrap only the risky part, not the whole formula: =B2*IFERROR(VLOOKUP(...),0), not =IFERROR(SUM(...)*VLOOKUP(...),0). • Sum while skipping errors: =AGGREGATE(9,6,D2:D100) — 9 = SUM, 6 = ignore error values. • Don’t add IFERROR while you’re still building a formula: look at the errors, fix the cause, then wrap. • If errors should be highlighted rather than hidden, use conditional formatting with the formula =ISERROR(A2).
Has ExcelLab been useful?
Support the project and help us release new lessons and exercises.