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.
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.
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(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(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.
| Question | IFERROR | IFNA | XLOOKUP if_not_found |
|---|---|---|---|
| #N/A from a missed lookup | Replaced | Replaced | Replaced |
| #DIV/0! | Replaced | Still #DIV/0! | Not what this argument is for |
| #NAME? from a typo | Replaced, so the typo is hidden | Still #NAME? | Still #NAME? |
| Best use | A result you are willing to replace no matter which error occurred | Lookups | Lookups, when you have XLOOKUP |
| Versions | Excel 2007 and later, Google Sheets | Excel 2013 and later, Google Sheets | Excel 2021, Microsoft 365, Google Sheets |
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.
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.
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Product | Price | Qty | Find | |
| 2 | Pen | 1.5 | 4 | Book | |
| 3 | Book | 12 | 2 | ||
| 4 | Lamp | 24 | 1 |
=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") → MissingThe 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.
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.
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.
It documents that the fallback is about the match, not about every possible error. You do not need IFNA around it.
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.
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.
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.
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.
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.
Free drills are open with no account. Premium drills show the problem to everyone and grade the sheet for subscribers.
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.
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.
Yes. #SPILL! is an error, so IFERROR replaces it. That can hide a blocked dynamic array. IFNA does not catch #SPILL!.
"" 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.