The IFNA function
IFNA is a more careful IFERROR. It catches only #N/A, the error a lookup gives when it can't find something, and lets every other error through.
That way a missing code shows a friendly message, while a genuine mistake, like a wrong column number, still shows up as an error you'll notice.
=IFNA(value, value_if_na)
Arguments
- value
- The formula to check, usually a lookup.
- value_if_na
- What to show if that formula returns #N/A.
Try it
=IFNA(VLOOKUP(D2,A2:B6,2,FALSE),"Not covered") in E2. BS is in the list, so the lookup works and IFNA passes South West straight through. Change D2 to NE to see the fallback.
E2
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Area | Region | Postcode area | Region | ||
| 2 | LS | Yorkshire | BS | South West | ||
| 3 | M | North West | ||||
| 4 | B | Midlands | ||||
| 5 | BS | South West | ||||
| 6 | CF | Wales | ||||
| 7 | ||||||
| 8 |
Edit the formula in E2, or change the data, and press Enter.
More examples
| Formula | Result | What it does |
|---|---|---|
| =IFNA(VLOOKUP("NE",A2:B6,2,FALSE),"Not covered") | Not covered | NE isn't listed, so the #N/A is replaced. |
| =IFNA(VLOOKUP("LS",A2:B6,3,FALSE),"Not covered") | #REF! | Column 3 doesn't exist. That's a real mistake, so IFNA doesn't hide it. |
| =IFNA(MATCH("M",A2:A6,0),0) | 2 | Works with MATCH too; 0 would mean not found. |
Tips
- Use IFNA around VLOOKUP, HLOOKUP and MATCH. XLOOKUP has its own if_not_found argument, so it rarely needs one.
- IFNA is in Excel 2013 and later.
Common mistakes
- IFNA doesn't stop a #DIV/0! or #VALUE!.That's by design: it only catches #N/A. Use IFERROR if you really want to catch everything.
- The fallback shows for codes that are in the list.The lookup isn't finding them, often because of spaces or text-versus-number codes. Fix the data rather than relying on the fallback.
Practise IFNA with instant feedback
Type real formulas into a working spreadsheet and get told straight away whether they work.