Sub topic 5
IFERROR or IFNA: which one to use
This chapter assumes you can enter and copy formulas, use relative and absolute references, and write a basic IF and VLOOKUP. It compares the two error handlers so you can pick the right one for each formula.
The difference in scope
IFERROR catches every error value. IFNA catches only #N/A. Both take two arguments: the formula to try, and the value to return if it fails.
| Function | Errors caught | Errors still shown |
|---|---|---|
| IFERROR | #DIV/0!, #N/A, #VALUE!, #REF!, #NAME?, #NUM!, #NULL! | None |
| IFNA | #N/A | All the others |
#N/A means "a value is not available". A lookup returns it when the item you searched for is not in the list. That is often an expected result, such as a new product that has no price yet. The other errors usually point to a mistake in the workbook.
The same formula, two handlers
Suppose column E holds product codes and $A$2:$B$100 holds codes and prices. This formula handles only a missing code:
=IFNA(VLOOKUP(E2, $A$2:$B$100, 2, FALSE), "Not found")Now suppose someone deletes column B. The lookup range shrinks, and the column index 2 no longer fits inside it, so VLOOKUP returns #REF!. With IFNA, the #REF! stays visible and you notice the problem. With IFERROR, every row quietly shows "Not found", and the broken workbook looks like a data gap.
=IFERROR(VLOOKUP(E2, $A$2:$B$100, 2, FALSE), "Not found")This second version hides the damage. Every row shows a plausible message, so nothing tells you the formula itself is broken.
How to decide
Ask what you expect to go wrong, then catch only that.
- If the failure you expect is a missing lookup value, use IFNA.
- If the expected failure is a zero divisor, test it directly with IF (see below), or use IFERROR if you accept that any error becomes the fallback.
- If the formula can fail in several expected ways and you want one fallback for all of them, use IFERROR.
- If you are unsure, start with the narrower handler. A visible error is easier to fix than a hidden one.
=IF(B2=0, "", A2/B2)This formula checks the divisor first. Only the zero case is handled, so an error from a text value in A2 still shows.
Where IFERROR is reasonable
IFERROR fits when any failure means the same thing to the reader. A division in a report is a typical case. If a blank or zero is the right answer whenever the division cannot be done, one fallback is enough.
=IFERROR(A2/B2, 0)Be aware that 0 and "" behave differently in later formulas. A later SUM treats 0 as a number. It ignores "" because that is text. Arithmetic such as =C2*2 on a cell that holds "" returns #VALUE!, so the error moves downstream. A later chapter covers replacement values in more detail.
A quick comparison of behavior
The diagram shows how each function treats a failing formula.
Common mistakes
- Wrapping a long formula in IFERROR "to be safe". Wrap only the part that can fail, or use IFNA.
- Using IFERROR on a lookup. A broken range or wrong column number gets hidden along with genuine misses.
- Returning "" and then doing math on the result. The cell looks blank but is text.
- Leaving the fallback as 0 for a missing price. A zero looks like real data and can be summed, while "Not found" is obvious.
Exercise
A price lookup is =IFERROR(VLOOKUP(E2, $A$2:$B$100, 2, FALSE), 0). A colleague changes the column index to 5 by mistake, and the sheet now shows 0 for every price. Which function would have exposed the mistake, and why?
Show answer
IFNA would have exposed it. A column index of 5 is outside a two-column range, so VLOOKUP returns #REF!. IFNA does not catch #REF!, so the error would have appeared in every row. IFERROR turned it into 0, which looks like a valid price.
Exercise
Which handler would you use for =A2/B2 if B2 is sometimes 0 and you want only that case replaced with a blank?
Show answer
Use an IF check on the divisor: =IF(B2=0, "", A2/B2). It handles only the zero-divisor case, so other errors remain visible. IFNA would not help because a zero divisor gives #DIV/0!, not #N/A.