DEV Community

SheetError
SheetError

Posted on Originally published at sheeterror.com AI-assisted

IFERROR vs IFNA in Google Sheets: hide #N/A without hiding #REF! and #DIV/0!

A lookup miss is #N/A. A deleted reference is #REF!. A zero divisor is #DIV/0!. IFERROR treats those as the same blank. IFNA does not. If you wrap first and read later, a broken index looks like “not found.”

Why it happens

IFERROR(value, fallback) replaces any error with the fallback: #N/A, #REF!, #DIV/0!, #VALUE!, #NAME?, #NUM!, and a parse #ERROR!.

IFNA(value, fallback) replaces only #N/A. Every other error stays in the cell.

A dashboard that should say “no sku” used IFERROR and now also says “no sku” when someone deletes a column, types VLOKUP, or divides by a blank. That is the bug this comparison exists for.

Reproduce it in a minute

  1. Open a blank spreadsheet. In A1 type sku, B1 name. A2 101, B2 Widget. D1 lookup. D2 999 — that sku is not in column A.

  2. A real miss. In E2 enter:

=VLOOKUP(D2,A2:B2,2,FALSE)
Enter fullscreen mode Exit fullscreen mode

E2 shows #N/A. The tooltip is Did not find value '999' in VLOOKUP evaluation. Leave E2 broken.

  1. A bad index, not a miss. In F2 enter:
=VLOOKUP(A2,A2:B2,3,FALSE)
Enter fullscreen mode Exit fullscreen mode

F2 shows #REF!. Sku 101 is on the sheet. Index 3 is past a two-column range. Use a key that exists so this cell cannot be mistaken for #N/A.

  1. A zero divisor. In G2 type 0. In G3 enter:
=1/G2
Enter fullscreen mode Exit fullscreen mode

G3 shows #DIV/0!. You now have three different errors on one sheet. Leave them broken.

  1. IFERROR on all three. In E6 enter:
=IFERROR(VLOOKUP(D2,A2:B2,2,FALSE),"none")
Enter fullscreen mode Exit fullscreen mode

E6 shows none. In F6 enter:

=IFERROR(VLOOKUP(A2,A2:B2,3,FALSE),"none")
Enter fullscreen mode Exit fullscreen mode

F6 shows none. In G6 enter:

=IFERROR(1/G2,"none")
Enter fullscreen mode Exit fullscreen mode

G6 shows none. The miss, the bad index, and the divide all look identical.

  1. IFNA on all three. In E9 enter:
=IFNA(VLOOKUP(D2,A2:B2,2,FALSE),"none")
Enter fullscreen mode Exit fullscreen mode

E9 shows none. In F9 enter:

=IFNA(VLOOKUP(A2,A2:B2,3,FALSE),"none")
Enter fullscreen mode Exit fullscreen mode

F9 is still #REF!. In G9 enter:

=IFNA(1/G2,"none")
Enter fullscreen mode Exit fullscreen mode

G9 is still #DIV/0!. Only the lookup miss became none.

  1. Confirm the miss before you wrap. Type 101 in D2. E2 becomes Widget. Put 999 back. If changing the lookup value makes #N/A come and go, the function is working and the key is absent — or the key does not actually match.

The fix

Leave E2, F2, and G3 as the raw errors. Leave the IFERROR row in place so you can compare.

Lookups: IFNA. Keep E9: =IFNA(VLOOKUP(D2,A2:B2,2,FALSE),"none") returns none for 999 and still surfaces F9 #REF! if you copy the wrapper onto a bad index. That is the point.

When no match is not a valid result. Do not wrap. Fix the key, the range, or the table.

XLOOKUP already has a miss argument. The fourth argument (missing_value in Sheets; Excel callers know it as if_not_found) returns your fallback on #N/A only, same idea as IFNA. It does not swallow #REF! from a broken range. You do not need IFERROR around that.

Use IFERROR only when every error should look the same. A cell that should be blank whenever the input is unusable — any error, no distinction — is the case for IFERROR. A lookup column is not that case.

Do not wrap first. Read the raw error. If it is #N/A and a miss is allowed, IFNA. If it is anything else, fix that error.

Watch out for

  • Number vs text, and a trailing space, are still #N/A. Those are a key-mismatch, not a reason to switch to IFERROR. Confirm the miss, then wrap with IFNA only if a miss is allowed.
  • IFERROR around IMPORTRANGE hides the Allow access #REF!. That prompt is not a missing row. Click Allow access. Do not wrap that #REF!.
  • #NAME? is a misspelled function. IFERROR would print none for =VLOKUP(...). Fix the name.
  • Do not wrap first. If the raw cell is anything other than #N/A, fix that error.

Originally published on SheetError, a free library of Google Sheets error fixes (I run it).

This article was created with the help of AI.

Top comments (0)