Instant digital downloadExcel and Google SheetsSecure card checkout

Excel and Google Sheets how-to

Hide #N/A in VLOOKUP with IFERROR

Your order list has a code that is not in the price list, and VLOOKUP shows #N/A. IFERROR puts your own words there instead.

ABCDE
1CodePriceOrderPrice
2A1002.50Z999Not found
3A2004.00B30010.00
4B30010.00A1002.50
5B4007.25C5003.75
6C5003.75A200 Not found

Sample data. Price list in A:B, order codes in D, the formula in E2 is copied down. D6 has a space after A200.

The formula

Click the first Price cell under Order (E2) and type:

=IFERROR(VLOOKUP(D2,A:B,2,FALSE),"Not found")

E2 shows Not found: Z999 is not in the price list, so VLOOKUP alone would show #N/A. Copy it down and B300 shows 10.00, A100 2.50 and C500 3.75.

  • VLOOKUP(D2,A:B,2,FALSE) looks for D2 in the first column of A:B and brings back the 2nd column, the price.
  • FALSE means an exact match only.
  • IFERROR(…,"Not found") shows your words when the lookup fails, and the price when it works.

A blank or 0 instead

Two quotes with nothing between them leave the cell empty:

=IFERROR(VLOOKUP(D2,A:B,2,FALSE),"")

Use 0 when you multiply the price by a quantity:

=IFERROR(VLOOKUP(D2,A:B,2,FALSE),0)*2

That gives 0 for Z999. The blank version times 2 gives #VALUE!, because "" is text. A total of the column still works with words or blanks in it: =SUM(E2:E6) gives 16.25 (10 + 2.50 + 3.75), because SUM skips text.

IFNA: hide only #N/A

IFERROR hides every error, including your own mistakes. Ask for column 3 of a two column range by accident:

=IFERROR(VLOOKUP(D3,A:B,3,FALSE),"Not found")

It shows Not found, although B300 is in the list. IFNA only replaces #N/A, the "not in the list" error:

=IFNA(VLOOKUP(D3,A:B,3,FALSE),"Not found")

Now the cell shows an error (#REF! in Excel), so you can see and fix the column number. With the right column, =IFNA(VLOOKUP(D2,A:B,2,FALSE),"Not found") shows Not found for Z999, just like IFERROR.

The code is in the list but shows Not found

D6 holds "A200 " with a space at the end, so the exact match fails and E6 shows Not found. TRIM removes spaces at the ends before the lookup:

=IFERROR(VLOOKUP(TRIM(D6),A:B,2,FALSE),"Not found")

E6 now shows 4.00. Codes copied from emails, PDFs and other systems often carry these spaces.

Numbers stored as text

When the price list has number codes like 1002 but the order cell holds 1002 as text (it sits on the left of the cell, often after an import), Excel's exact match fails with #N/A. VALUE turns the text into a number first:

=VLOOKUP(VALUE(D2),A:B,2,FALSE)

The other way round, a list of codes stored as text and a number to find, add an empty text to the number:

=VLOOKUP(D2&"",A:B,2,FALSE)

Both find the match. =ISNUMBER(D2) shows TRUE for a real number and FALSE for text.

Always end with FALSE

Without FALSE, VLOOKUP looks for the closest match in a sorted list and can bring back the wrong price with no error at all:

=VLOOKUP("B350",A2:B6,2)

That gives 10.00, the price of B300, although B350 is not in the list. IFERROR cannot catch it, because there is no error. With FALSE:

=IFERROR(VLOOKUP("B350",A2:B6,2,FALSE),"Not found")

shows Not found. VLOOKUP, IFERROR, IFNA, TRIM and VALUE work in every current version of Excel and in Google Sheets. In Excel 2021 and later, Microsoft 365 and Google Sheets, XLOOKUP has its own "not found" part and matches exactly by default.

Templates with the math already done

Rather skip the formulas? These templates come with every formula built and checked, plus a filled-in sample.

More how-tos