FxFormula Drills

IFERROR vs IFNA

IFERROR returns its second argument when the first argument is any error, including #DIV/0!, #VALUE!, #REF!, #NAME?, and #N/A. IFNA returns its second argument only for #N/A and lets every other error through. Use IFNA around a lookup. Use IFERROR when you have decided that any failure, such as a divide by zero, should show a label instead of an error code.

Syntax

IFERROR

IFERROR(value, value_if_error)

value is the formula you want. value_if_error is what to show if that formula produces an error. Both arguments are required. A successful formula returns its normal result.

IFNA

IFNA(value, value_if_na)

Same shape, narrower net. Only #N/A is replaced. #DIV/0! and #VALUE! still appear, which is what you want while a formula might be mistyped.

XLOOKUP's if_not_found

XLOOKUP(lookup_value, lookup_array, return_array, if_not_found)

The fourth argument covers a failed match only, similar to IFNA. It does not hide a #VALUE! caused by a bad range. Available where XLOOKUP is available.

Comparison

QuestionIFERRORIFNAXLOOKUP if_not_found
#N/A from a missed lookupReplacedReplacedReplaced
#DIV/0!ReplacedStill #DIV/0!Not what this argument is for
#NAME? from a typoReplaced, so the typo is hiddenStill #NAME?Still #NAME?
Best useA result you are willing to replace no matter which error occurredLookupsLookups, when you have XLOOKUP
VersionsExcel 2007 and later, Google SheetsExcel 2013 and later, Google SheetsExcel 2021, Microsoft 365, Google Sheets

Worked examples

Division by zero is not a missing lookup

1/0 is #DIV/0!. IFERROR turns it into the word err. IFNA does not, because the error is not #N/A. That difference is the reason to pick one function on purpose.

No sheet inputs. Both formulas divide 1 by 0.

  • =IFERROR(1/0,"err") → err
  • =IFNA(1/0,"err") → #DIV/0!

IFERROR treats every error as a reason to show err. IFNA shows err only for #N/A, so the divide-by-zero remains visible. If you wrap a ratio in IFERROR too early, a zero denominator looks like a successful 'err' label and you stop looking for the bad input.

A product that is not on the list

Desk is not in the price list. An exact VLOOKUP returns #N/A. Both IFNA and IFERROR can replace that particular error. XLOOKUP can do it without a wrapper.

Pen, Book, and Lamp. Desk is absent.
RowABCDE
1ProductPriceQtyFind
2Pen1.54Book
3Book122
4Lamp241
  • =VLOOKUP("Desk",A2:B4,2,FALSE) → #N/A
  • =IFNA(VLOOKUP("Desk",A2:B4,2,FALSE),"Missing") → Missing
  • =IFERROR(VLOOKUP("Desk",A2:B4,2,FALSE),"Missing") → Missing
  • =XLOOKUP("Desk",A2:A4,B2:B4,"Missing") → Missing

The bare VLOOKUP is #N/A, which is the honest result of an exact miss. IFNA replaces only that. IFERROR also replaces it, and would also replace a #REF! if the column index were wrong. XLOOKUP's fourth argument is the lookup-shaped version of IFNA. Prefer IFNA or if_not_found around lookups so a mistake in the formula still shows up.

When to use which

Use IFNA on VLOOKUP, HLOOKUP, MATCH, and INDEX/MATCH

A missing key is #N/A. That is the error you decided to translate into "Missing" or a blank. Leave #REF! and #VALUE! visible so a bad index or a shifted range is still obvious.

Use IFERROR on a ratio or a parse you are willing to blanket

A cost divided by units, when units can be zero, is a reasonable IFERROR if the label for that case is a decision you have made. The premium ratio drill is this situation.

Prefer XLOOKUP's fourth argument when you have XLOOKUP

It documents that the fallback is about the match, not about every possible error. You do not need IFNA around it.

Common mistakes

IFERROR while you are still writing the formula

The wrapper hides the #NAME? from a misspelled function. Build the lookup or the division first. Add the wrapper after the success case returns the right value.

Returning 0 for a missing price

IFNA(VLOOKUP(...), 0) makes a missing product look free. A later SUM will treat it as a real zero. Return a blank with "" or a word such as Missing unless zero is truly the business rule.

Expecting IFNA to catch #DIV/0!

The first example is the counterexample. IFNA(1/0, "err") is still #DIV/0!. Use IFERROR for that error, or test the denominator with IF before you divide.

Wrapping a whole chain of formulas

IFERROR around a long expression makes every failure look the same. Wrap the part that you know can fail, such as the lookup, and let the arithmetic around it stay bare.

Versions and compatibility

IFERROR is in Excel 2007 and later and in Google Sheets. IFNA is in Excel 2013 and later and in Google Sheets. Excel 2010 has IFERROR but not IFNA.

XLOOKUP's if_not_found argument requires Excel 2021, Excel 2024, Microsoft 365, Excel for the web, or Google Sheets.

The error codes in the examples, #N/A and #DIV/0!, are the same codes Google Sheets shows for a missed lookup and for division by zero.

Practice on Formula Drills

Free drills are open with no account. Premium drills show the problem to everyone and grade the sheet for subscribers.

Free exercises

Premium exercises

Function pages

FAQ

When should I use IFERROR instead of IFNA?

When more than one kind of error should show the fallback. A ratio that might divide by zero is the common case. For a lookup, IFNA is the narrower tool.

Can the fallback be a formula?

Yes. IFERROR(first try, second try) calculates the second formula only when the first errors. That is a useful way to attempt one match and then another. Keep each attempt small enough to read.

Does IFERROR catch #SPILL!?

Yes. #SPILL! is an error, so IFERROR replaces it. That can hide a blocked dynamic array. IFNA does not catch #SPILL!.

What fallback should a blank cell use?

"" produces a blank-looking cell. It is still a formula, so ISBLANK on that cell is false. COUNTA will count it. Use "" when the report should look empty, and remember it is not the same as a cell that was never filled.