IFERROR and IFNA in Excel: catching errors without hiding the real ones
A #DIV/0! or #N/A looks messy, but it's information too. On the sheets of a swimming pool and a bike courier, you'll see how to catch them neatly, and when to leave them alone.
Christophe, founder of Lurndo
· 6 min read
IFERROR shows something else when a formula returns an error value, as in =IFERROR(E11/D11,"-"). It catches every error, including one from a typo in your formula. IFNA is more careful: it only catches #N/A, the error for "not found", and lets the rest through. So use IFNA around a lookup, and only wrap IFERROR around a formula once it works.

What do IFERROR and IFNA do in Excel?
IFERROR shows something else when a formula returns an error value, and otherwise just shows the result. =IFERROR(E11/D11,"-") divides E11 by D11 and shows a dash if that doesn't work. IFNA does the same, but only for the #N/A error, which you get when a lookup finds nothing. In a Dutch copy of Excel, they're called ALS.FOUT and ALS.NB.
Both are handy, and both can hide exactly what you should have seen. That's why the examples below use two sheets from our Excel course: The Splash swimming pool in Tamworth and Flying Velo bike couriers in Manchester. If you'd rather learn it step by step, follow the lesson on error values.
How do you write IFERROR and IFNA?
=IFERROR(value,value_if_error)
=IFNA(value,value_if_na)| Argument | What it is | Example |
|---|---|---|
| value | The calculation or formula you're checking | E11/D11 |
| value_if_error | What the cell shows on an error: text, a number or another formula | "-" |
With Dutch or Belgian regional settings you'd write =ALS.FOUT(E11/D11;"-") and =ALS.NB(…;"-"). If the formula works, the function does nothing and you see the result itself. If you leave the second argument empty, IFERROR returns an empty string (Microsoft).
Which errors does IFERROR catch?
All seven error types Microsoft lists for it (Microsoft). Read them before you make them disappear, because each one tells you what's wrong.
| Error | Meaning | IFERROR | IFNA |
|---|---|---|---|
| #DIV/0! | Dividing by zero or an empty cell | Catches it | Leaves it |
| #N/A | Not found | Catches it | Catches it |
| #VALUE! | Calculating with text, or the wrong kind of argument | Catches it | Leaves it |
| #REF! | A reference that doesn't exist | Catches it | Leaves it |
| #NAME? | A name Excel doesn't know, often a typo | Catches it | Leaves it |
| #NUM! | A number that isn't possible | Catches it | Leaves it |
| #NULL! | Two ranges that don't intersect | Catches it | Leaves it |
How do you catch #DIV/0!?
Manager Dave at The Splash wants to know what each member pays per visit: the amount in column E divided by the visits in column D. Sara has never been and Laura's cell is empty, so the division returns #DIV/0! for both. An empty cell counts as 0 in a calculation.
| Row | A: Name | D: Visits | E: Paid (£) | G: Per visit |
|---|---|---|---|---|
| 2 | Jack | 3 | 15 | 5.00 |
| 3 | Nora | 22 | 240 | 10.91 |
| 4 | Mila | 9 | 25 | 2.78 |
| 5 | Rita | 15 | 240 | 16.00 |
| 6 | Laura | (empty) | 10 | #DIV/0! |
| 7 | Rory | 6 | 25 | 4.17 |
| 8 | Jim | 18 | 240 | 13.33 |
| 9 | Will | 4 | 20 | 5.00 |
| 10 | Hannah | 11 | 25 | 2.27 |
| 11 | Sara | 0 | 240 | #DIV/0! |
This is one of the clean uses of IFERROR. The error isn't a mistake: there's nothing to work out for Sara, and Dave wants a calm sheet. Try it yourself in Sara's row.
Try it: Sara without the error
In G11, work out what Sara pays per visit: the amount in E11 divided by the visits in D11. Show a dash "-" if that gives an error.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Name | Age | Pass | Visits | Paid | Category | Per visit | |
| 2 | Jack | 9 | Single | 3 | £15.00 | |||
| 3 | Nora | 34 | Annual | 22 | £240.00 | |||
| 4 | Mila | 15 | Monthly | 9 | £25.00 | |||
| 5 | Rita | 67 | Annual | 15 | £240.00 | |||
| 6 | Laura | 41 | Single | £10.00 | ||||
| 7 | Rory | 7 | Monthly | 6 | £25.00 | |||
| 8 | Jim | 72 | Annual | 18 | £240.00 | |||
| 9 | Will | 28 | Single | 4 | £20.00 | |||
| 10 | Hannah | 12 | Monthly | 11 | £25.00 | |||
| 11 | Sara | 55 | Annual | 0 | £240.00 | |||
| 12 |
Your formula ran in your own browser, on a real calculation engine, and then again on a hidden version of the sheet with other amounts.
To be more precise, test the divisor with the IF function: =IF(D11=0,"-",E11/D11). That only catches division by zero. Microsoft warns that IFERROR suppresses all errors, not only #DIV/0! (Microsoft).
How do you catch #N/A in a VLOOKUP?
With IFNA, around the lookup. Dispatcher Kyle at Flying Velo looks up the customer's area for each ride. The customer list is in L2:M6: the code in column L, the area in column M. Ride R10 is for a new customer, K06, who isn't on the list yet. =VLOOKUP(B11,L2:M6,2,FALSE) returns #N/A there.
| Code | Area |
|---|---|
| K01 | Manchester |
| K02 | Burnage |
| K03 | Manchester |
| K04 | Didsbury |
| K05 | Withington |
That's not Kyle's mistake, but a real answer: this customer doesn't exist yet. Let's say so neatly. If VLOOKUP is new to you, the lesson takes it slowly, and the hints below will walk you through it here.
Try it: a new customer
In G11, look up the area for the customer in B11 in the list L2:M6, with VLOOKUP. Show "New customer" if the code isn't there, with IFNA.
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Ride | Customer | Zone | Km | Weight | Price | Area | Surcharge | Customer name | Name | Code | Area | From km | Price | |||
| 2 | R01 | K03 | Centre | 2.5 | 3 | Bloom Bakery | K01 | Manchester | 0 | £6.00 | |||||||
| 3 | R02 | K01 | Suburbs | 7.2 | 12 | Book Nook | K02 | Burnage | 3 | £9.00 | |||||||
| 4 | R03 | K05 | Docks | 11.4 | 25 | Cygnet Café | K03 | Manchester | 6 | £12.00 | |||||||
| 5 | R04 | K02 | Centre | 1.8 | 1 | Dot Print | K04 | Didsbury | 10 | £18.00 | |||||||
| 6 | R05 | K03 | Suburbs | 5.5 | 8 | Fork & Spoke | K05 | Withington | |||||||||
| 7 | R06 | K04 | Docks | 9.9 | 18 | ||||||||||||
| 8 | R07 | K01 | Centre | 3 | 4 | ||||||||||||
| 9 | R08 | K02 | Suburbs | 6 | 10 | Zone | Centre | Suburbs | Docks | ||||||||
| 10 | R09 | K05 | Docks | 14 | 30 | Surcharge | £0.00 | £2.00 | £5.00 | ||||||||
| 11 | R10 | K06 | Centre | 4.2 | 2 | ||||||||||||
| 12 | |||||||||||||||||
| 13 | Position | Weight | Centre | Suburbs | Docks | Class | Medium | ||||||||||
| 14 | Light | £0.00 | £1.00 | £3.00 | Zone | Docks | |||||||||||
| 15 | Medium | £2.00 | £3.00 | £5.00 | Result | ||||||||||||
| 16 | Heavy | £4.00 | £6.00 | £8.00 | |||||||||||||
| 17 |
XLOOKUP has this built in, as its fourth argument: =XLOOKUP(B11,L2:L6,M2:M6,"New customer") does the same without IFNA. It's shorter and just as safe. How the two lookups differ is covered in VLOOKUP vs XLOOKUP.
When does IFERROR hide a real mistake?
Whenever your formula itself is broken. IFERROR doesn't know why there's an error, only that there is one. Say Kyle accidentally asks for column 3 from a list of two columns. With IFERROR he notices nothing; with IFNA he does:
| Formula, for ride R01 with customer K03 | Result |
|---|---|
=VLOOKUP(B2,L2:M6,3,FALSE) | #REF! |
=IFERROR(VLOOKUP(B2,L2:M6,3,FALSE),"New customer") | New customer |
=IFNA(VLOOKUP(B2,L2:M6,3,FALSE),"New customer") | #REF! |
With IFERROR, every ride says "New customer", even for your most loyal customers, and nobody gets a warning. The same goes for a typo: =IFERROR(SUMM(E2:E11),0) shows £0 instead of #NAME?, and the sheet looks perfectly healthy.
Write your formula without IFERROR first and check it works. Only wrap the safety net around it once you know which error you're expecting.
What should you show instead of the error?
That's not a detail, because whatever you put there keeps calculating. Dave wants the average per visit from column G. With a dash for Laura and Sara, AVERAGE skips that text and he gets £7.43. With a 0, he gets £5.95: two members who tell you nothing about the price drag the average down.
| On an error you show | Effect in AVERAGE | Effect in =G6*2 |
|---|---|---|
"-" or "" | Skipped, £7.43 | #VALUE!, because it's text |
0 | Counted, £5.95 | 0 |
| The error itself | #DIV/0! | #DIV/0! |
So only pick 0 if zero is really the answer. A cell that looks empty with "" holds text, and you can't multiply that. For more on what an average does and doesn't include, read the article on AVERAGE.
Which functions go with these?
There's a small group around an error value, and each member has a job of its own. Here they are with the example that suits them best.
| Function | When | Example |
|---|---|---|
| IFERROR | The error is expected, whichever it is | =IFERROR(E2/D2,"-") |
| IFNA | A lookup is allowed to find nothing | =IFNA(VLOOKUP(…),"Unknown") |
| IF | You know which case you want to catch | =IF(D2=0,"-",E2/D2) |
| XLOOKUP | A lookup with an alternative of its own | =XLOOKUP(B2,L2:L6,M2:M6,"Unknown") |
An average with no rows returns #DIV/0! too, as you'll see in AVERAGEIF and AVERAGEIFS. Every function is on the Excel cheat sheet with its Dutch name, and the 12 most useful Excel formulas give you a broader start. If you want to learn to read error values on a real sheet, follow module 3 of the Excel course. It's free.
Frequently asked questions
What's the difference between IFERROR and IFNA?
IFERROR catches every error value, from
How do you replace
With =IFNA(VLOOKUP(B2,L2:M6,2,FALSE),0), or "" in place of the 0. Think before you do. A 0 counts in an average, and "" is text, which can give an error if you calculate with it further on. A word such as Unknown is often the most honest.
How do you avoid
Wrap IFERROR around the division, as in =IFERROR(E2/D2,"-"), or test the divisor with IF: =IF(D2=0,"-",E2/D2). The second form is more precise, because it only catches division by zero. A typo or text in the cells still shows up as an error value.
Should you use IFERROR with XLOOKUP?
Usually not. XLOOKUP has its own fourth argument for what to show when it finds nothing, as in =XLOOKUP(B11,L2:L6,M2:M6,"Unknown"). That does the same as IFNA, but the formula stays shorter, and any other error in it stays visible. So IFERROR isn't needed here.
Why does IFERROR always show my alternative?
Because the formula returns an error in every row, and that's being hidden. Take IFERROR off for a moment and look at the error underneath. It's often a typo in a function name, a column number outside the range or a reference that no longer exists. Fix that, then put IFERROR back.
Practise this in the course
Every lesson explains first and then lets you practise yourself, with a real spreadsheet in your browser.
- IFERRORLogic · Catching error values
- VLOOKUPLookups · Looking up in a column
- XLOOKUPLookups · Looking up in any direction
Sources
- Microsoft Support, IFERROR function
- Microsoft Support, IFNA function
- Microsoft Support, How to correct a
Christophe, founder of Lurndo
Christophe builds Lurndo from Belgium, with short, playful exercises for SQL, Excel, HTML & CSS and touch typing that show straight away what your answer does. On this blog, Christophe answers the questions people run into while learning, with sources you can check yourself.
Read next
AVERAGEIF and AVERAGEIFS examples: one condition or several, and why you get #DIV/0!Two functions with nearly the same name and their arguments in a different order. On a charity shop's real sheet you'll see when to use which, and where an average can lead you astray.Excel · · 7 min read
Excel COUNTIFS examples: counting with multiple criteria, including between two valuesHow many items over £5 did Grace sell? On a charity shop's real sheet you'll see how COUNTIFS counts row by row, and you can write one yourself right away.Excel · · 7 min read