Home › Excel functions › IFERROR
IFERROR in Excel: Syntax, Examples and When Not to Use It
IFERROR returns the result of a formula, unless that formula produces an error, in which case it returns a value you choose instead. It's the quickest way to turn a sheet full of #N/A and #DIV/0! into something readable.
In this guide
IFERROR syntax
=IFERROR(value, value_if_error)| Argument | What it means |
|---|---|
| value | The formula or value to check, usually your normal calculation. |
| value_if_error | What to return if value results in an error: a number, text, an empty string "" or another formula. |
IFERROR catches every error type: #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME? and #NULL!.
Example: hide #DIV/0!
You want the average price per unit, but one product hasn't sold anything yet.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Product | Revenue | Units | =B/C | With IFERROR |
| 2 | Apple | 350 | 100 | 3.5 | 3.5 |
| 3 | Banana | 0 | 0 | #DIV/0! | 0 |
| 4 | Cherry | 120 | 40 | 3 | 3 |
Column D uses =B2/C2. Banana has 0 units, and dividing by zero gives #DIV/0!. Column E wraps the same formula:
Now Banana shows 0, and the other rows still show their normal result. Use "" instead of 0 to leave the cell empty.
IFERROR practice: try it yourself
Reading is one thing, typing it is another. Build the formula below step by step: the tips tell you what to type next, and you can click or drag across cells to add them, just like in Excel.
Task: Look up the stock of Kiwi in F2 and show "Not found" instead of an error: =IFERROR(VLOOKUP(E2,A2:B6,2,FALSE),"Not found")
Example: a friendly message for VLOOKUP
When VLOOKUP can't find a value it returns #N/A. Wrap it to show a message instead:
If the product in E2 exists, you get its price; if not, you get Not found. With XLOOKUP you don't need IFERROR for this: it has a built-in if_not_found argument.
IFNA: only catch #N/A
IFNA works like IFERROR but only catches #N/A. Other errors still show.
For lookups this is usually the better choice. "Not found" is an expected situation, but a #REF! or #NAME? means something is broken in your formula, and you want to see that.
Sum or average a range that contains errors
SUM and AVERAGE give up as soon as one cell in the range holds an error: if a lookup in B3 returns #N/A, =SUM(B2:B5) returns #N/A as well. Put IFERROR around the range, inside the SUM:
| A | B | |
|---|---|---|
| 1 | Region | Sales |
| 2 | North | 420 |
| 3 | South | #N/A |
| 4 | East | 310 |
| 5 | West | 275 |
| 6 | Total | 1005 |
IFERROR turns the #N/A into 0 and SUM adds up the rest: 1005. In Excel 2019 and older, confirm this formula with Ctrl+Shift+Enter, because IFERROR has to check every cell of the range.
For an average, use an empty string instead of 0: =AVERAGE(IFERROR(B2:B5, "")) gives 335, the average of the three real values. With 0 the error would count as a sale of zero and you would get 251.25.
AGGREGATE does the same without IFERROR and without Ctrl+Shift+Enter: =AGGREGATE(9, 6, B2:B5) sums and skips errors (9 = sum, 6 = ignore errors). Use 1 instead of 9 for the average.
When not to use IFERROR
IFERROR hides every error, including real mistakes. A typo in a function name, a deleted column or a wrong range all disappear behind your friendly message, and you might never notice the numbers are wrong.
- Get the formula working first, then add IFERROR.
- Prefer IFNA for lookups, so other errors stay visible.
- Don't return 0 when an error should be looked into: a zero looks like a real result and flows into totals and averages.
- For division, an explicit check is clearer:
=IF(C2=0, "", B2/C2).
Not sure what an error means? See Excel errors explained.
More IFERROR examples
Copy a formula and change the ranges to match your own data.
| What you want | Formula |
|---|---|
| Divide, and show 0 instead of #DIV/0! | =IFERROR(A2/B2, 0) |
| Empty cell instead of #N/A when a lookup finds nothing | =IFERROR(VLOOKUP(E2, A2:C100, 3, FALSE), "") |
| Look in a second table when the first finds nothing | =IFERROR(VLOOKUP(E2, A2:C100, 3, FALSE), IFERROR(VLOOKUP(E2, Sheet2!A2:C100, 3, FALSE), "")) |
| Only replace #N/A, keep other errors visible | =IFNA(XLOOKUP(E2, A2:A100, C2:C100), 0) |
Keep learning
Frequently asked questions
What's the difference between IFERROR and IFNA?
IFERROR catches all error types. IFNA only catches #N/A, which is what lookup functions return when nothing is found, so other errors remain visible.
How do I make IFERROR return a blank cell?
Use an empty string as the second argument: =IFERROR(B2/C2, "").
Can I use IFERROR with a whole range?
In Microsoft 365 you can: =IFERROR(B2:B10/C2:C10, 0) spills a result for every row. In older versions, write the formula for one row and copy it down.
Does IFERROR slow down my spreadsheet?
Not noticeably in normal workbooks. The bigger risk is hiding mistakes, not speed.
How do I look in a second table if the first lookup fails?
Nest two IFERRORs: =IFERROR(VLOOKUP(E2, A2:C100, 3, FALSE), IFERROR(VLOOKUP(E2, Sheet2!A2:C100, 3, FALSE), "")). Excel tries the first table, then the second, and shows an empty cell if neither has the value.
Why doesn't IFERROR work?
IFERROR only catches errors. If a lookup returns 0 or the wrong value, there is no error to catch: check the lookup itself, for example exact match (FALSE as the last argument) and extra spaces in the data.
Which Excel versions have IFERROR?
IFERROR exists since Excel 2007, IFNA since Excel 2013. In older files you will see =IF(ISERROR(B2/C2), 0, B2/C2): the same result, but the calculation is written twice.
Why doesn't a cell with "" count as empty?
=IFERROR(B2/C2, "") returns empty text, not a truly empty cell. COUNTA counts it, ISBLANK returns FALSE and =E2+1 gives #VALUE!. Test with =E2="" instead of ISBLANK, or return 0 if you keep calculating with the result.
Can I show a different message for each type of error?
Yes, with ERROR.TYPE in the second argument: =IFERROR(B2/C2, IF(ERROR.TYPE(B2/C2)=2, "No units", "Check data")). ERROR.TYPE returns 2 for #DIV/0! and 7 for #N/A, so every other error shows "Check data".