formulastreak

VLOOKUP returns #N/A when the value exists

Updated · Checked on a live sheet · Excel and Google Sheets

The most likely fix

When VLOOKUP can't find a value you can see, the two values look alike but aren't: one is text and the other a number, or one has a space you can't see. Clean the lookup value inside the formula, with VALUE for numbers or TRIM for spaces, and check that the last argument is FALSE.

Fix it yourself

The formula in M2 shows the problem. Edit it to the fixed version and watch the sheet recalculate.

M1 holds the SKU with a trailing space, so it doesn't equal “PL-104” · edit M2 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultM2 = #N/A
GHIJKLM
1SKUProductPriceStockSKUPL-104
2PL-101Fern$9.5040Product#N/A
3PL-104Monstera$34.0012
4PL-107Snake plant$22.0025
5PT-210Terracotta pot$12.5060
6PT-212Ceramic pot$19.0018
7TL-301Watering can$18.009
8SL-401Potting mix$7.2580

Shows the problem

=VLOOKUP(M1,G2:H8,2,FALSE)

Fixed

=VLOOKUP(TRIM(M1),G2:H8,2,FALSE)

Causes, most likely first

  1. 1A space you can't see

    “PL-104 ” with a trailing space is a different value from “PL-104”. Data typed by hand or exported from other systems often carries spaces at the start or end. TRIM removes them, along with doubled spaces inside, so wrap the lookup value: VLOOKUP(TRIM(M1), …). If the spaces are in the table instead, clean that column once.

    Wrong

    =VLOOKUP(M1,G2:H8,2,FALSE)

    Fixed

    =VLOOKUP(TRIM(M1),G2:H8,2,FALSE)
  2. 2A number on one side, text on the other

    The number 2003 and the text “2003” look identical in a cell but never match. Order numbers and IDs imported from other systems are often text. Convert the lookup value to match the table: VALUE(M1) when the table holds numbers, M1&"" when it holds text. Lookup numbers stored as text shows how to tell which side is which.

    Wrong

    =VLOOKUP(M1,A2:C9,3,FALSE)

    Fixed

    =VLOOKUP(VALUE(M1),A2:C9,3,FALSE)
  3. 3A non-breaking space

    Text copied from web pages often contains a non-breaking space, CHAR(160). Microsoft's TRIM page notes that TRIM doesn't remove it, so TRIM alone still leaves #N/A. Replace it with a normal space first: TRIM(SUBSTITUTE(M1, CHAR(160), " ")).

    Wrong

    =VLOOKUP(TRIM(M1),G2:H8,2,FALSE)

    Fixed

    =VLOOKUP(TRIM(SUBSTITUTE(M1,CHAR(160)," ")),G2:H8,2,FALSE)
  4. 4The last argument is missing

    Without FALSE, VLOOKUP does an approximate match, which assumes the first column is sorted. On unsorted data it can return #N/A for a value that is there (or a wrong row; see VLOOKUP returns the wrong value). Always end an exact lookup with FALSE.

    Wrong

    =VLOOKUP(M1,G2:H8,2)

    Fixed

    =VLOOKUP(M1,G2:H8,2,FALSE)
  5. 5The table range slid when you filled the formula down

    A table written as G2:H8 moves down one row with each copy, so lower rows search a table that has lost its first rows. Lock it with $: $G$2:$H$8 (absolute references).

    Wrong

    =VLOOKUP(B2,G2:H8,2,FALSE)

    Fixed

    =VLOOKUP(B2,$G$2:$H$8,2,FALSE)

Stop it happening again

Fix the data at the source when you can: clean the key column once with TRIM, convert imported IDs to one type, and keep the cleaned column instead of the raw one. Make FALSE a habit, so every exact lookup ends with it. Lock the table with $ before you fill a lookup down. And when “not found” is a real possibility, decide what the cell should say with IFNA (or XLOOKUP's fourth argument) so a missing key shows a clear message instead of an error, but only after you've ruled out the causes above; otherwise IFNA would hide a fixable problem.

Questions

Why does VLOOKUP work for some rows and not others?

Usually the failing rows have the problem and the others don't: a few IDs typed by hand with a space, a few imported as text, or rows past the end of an unlocked table range. Check a failing key with =LEN(M1) (extra characters show up as a longer length) and =ISTEXT(M1).

Does XLOOKUP have the same problem?

Yes. XLOOKUP also needs the values to match exactly, type and characters, so spaces and text-versus-number mismatches give #N/A there too. It just can't make the missing-FALSE mistake, because exact match is its default.

In Google Sheets

Google Sheets behaves the same way: its VLOOKUP help says #N/A means the exact match of the search key wasn't found in the first column, and it recommends cleaning data and using FALSE. TRIM, SUBSTITUTE, CHAR and VALUE all exist in Sheets, so every fix on this page works there unchanged.

Why this happens

VLOOKUP compares values exactly when the last argument is FALSE: same characters, same type. A cell's appearance hides both the type (text or number) and invisible characters, which is why the value seems to exist. Fix the data once if you can; otherwise clean it inside the formula. The VLOOKUP vs XLOOKUP guide covers both functions, and the #N/A error page lists every cause of #N/A.

Practise this in 5 minutes

VLOOKUP is taught in Lesson 15: VLOOKUP (Unit 4, Lookups), on a live sheet with instant feedback. Pro

Open “VLOOKUP”

Get the formulastreak newsletter

Bite-sized formula tips you can use at work the next day, plus a heads-up when new free tools and lessons land. It arrives now and then, never in a flood.

No spam, unsubscribe in one click. We store your email, this consent and when you gave it. Details in our privacy policy.

Need a quick reference? The formula cheat sheet is free to read and print.