VLOOKUP returns #N/A when the value exists
Updated · Checked on a live sheet · Excel and Google Sheets
The most likely fix
Fix it yourself
The formula in M2 shows the problem. Edit it to the fixed version and watch the sheet recalculate.
| G | H | I | J | K | L | M | |
|---|---|---|---|---|---|---|---|
| 1 | SKU | Product | Price | Stock | SKU | PL-104 | |
| 2 | PL-101 | Fern | $9.50 | 40 | Product | #N/A | |
| 3 | PL-104 | Monstera | $34.00 | 12 | |||
| 4 | PL-107 | Snake plant | $22.00 | 25 | |||
| 5 | PT-210 | Terracotta pot | $12.50 | 60 | |||
| 6 | PT-212 | Ceramic pot | $19.00 | 18 | |||
| 7 | TL-301 | Watering can | $18.00 | 9 | |||
| 8 | SL-401 | Potting mix | $7.25 | 80 |
Shows the problem
=VLOOKUP(M1,G2:H8,2,FALSE)Fixed
=VLOOKUP(TRIM(M1),G2:H8,2,FALSE)Causes, most likely first
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.
TRIMremoves 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)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)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)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)5The table range slid when you filled the formula down
A table written as
G2:H8moves 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.
Sources
Official documentation the facts on this page were checked against.