Skip to content

Guide Data integrity

My VLOOKUP says #N/A but I can see the value in the list

The value is sitting there in the lookup range. You have checked it three times. The match still fails — because the two strings are not actually identical, and the difference is a character you cannot see.

VLOOKUP + XLOOKUP TRIM + CLEAN Excel + Google Sheets
My VLOOKUP says #N/A but I can see the value in the list
The short answer

An exact-match lookup compares the strings byte for byte, so a trailing space or a non-breaking space makes two values that look identical fail to match. TRIM alone does not fix it: TRIM only removes ordinary spaces, and text pasted from a web page usually contains a non-breaking space, which is a different character. Substitute the invisible characters first, then CLEAN, then TRIM — in that order.

Three different invisible characters, three different fixes

“There is a space in it” is usually right but rarely specific enough. There are three distinct culprits and only one of them is what people mean by a space:

CLEAN removes control characters but not the non-breaking space either — a non-breaking space is a printing character as far as Excel is concerned. So the standard advice, TRIM(CLEAN(A2)), misses the most common cause.

Copied from a webpageSmith + hidden spaceLooks identicalon screenCompared letter byletternot the sameLookup#N/A
Both cells look identical on screen. One has a character you cannot see, so the match fails and the row is reported as missing.
What you are seeing, and what actually happened
What you seeWhat actually happenedWhat fixes it
#N/A but the value is visibly presentThe two strings differ by a character you cannot seeClean both sides, then match
TRIM made no differenceA non-breaking space is not an ordinary spaceSUBSTITUTE the character out first
=A2=B2 returns FALSE for identical-looking textConfirms the strings genuinely differCompare LEN to find the extra character
It works after you retype the value by handRetyping produced clean characters; the imported one was dirtyClean the column rather than retyping it
Only some rows failOnly some values were pasted from the dirty sourceClean the whole column, not the failing rows

How to fix a lookup that fails on invisible characters

Cleaning the columnwhich order?Swap hidden spaces, then TRIMthe match worksTRIM on its ownhidden space stays, still fails
TRIM removes ordinary spaces only. The hidden one has to be swapped out first.
1

Confirm the strings really do differ

Before changing anything, prove the cause:

Are they actually the same?
=A2=B2          =LEN(A2)          =LEN(B2)

FALSE with different lengths means there are extra characters. FALSE with the same length means a character has been substituted — typically an ordinary space replaced by a non-breaking one.

2

Identify the character

To see exactly what you are dealing with:

What is that last character?
=CODE(RIGHT(A2,1))

32 is an ordinary space, 160 is a non-breaking space, and anything below 32 is a control character. Knowing which one tells you whether TRIM can help at all.

3

Clean with the chain in the correct order

Order matters and this is the whole trick. Replace the invisible characters first — while they are still there to be replaced — then let CLEAN and TRIM do their work:

The clean chain
=TRIM(CLEAN(SUBSTITUTE(SUBSTITUTE(A2,"[nbsp]"," "),"[zwsp]","")))

[nbsp] and [zwsp] stand for the literal invisible characters. Copy one out of your own data to type them, or use the free workbook below, which already has them in place.

4

Clean both sides, then match

This is the step people miss. Cleaning your lookup value while the lookup column is still dirty changes nothing. Add a cleaned helper column beside the lookup range, point the lookup at that, and clean the search value the same way.

Everything on this page, as a workbook you can use on your own data

The Excel Data Cleanup Kit — a seven-tab workbook that finds all nine of these faults in a pasted column and hands back a cleaned version, a five-page PDF guide, and a short read-me. Free, no email required.

  • Excel-Data-Cleanup-Workbook-Free.xlsx — paste a column, read the diagnosis, take the cleaned output
  • Excel-Data-Survival-Guide.pdf — the eight failures, the import routine that prevents them, every formula explained
Download the kit — free 121 KB .zip · Excel & Google Sheets

Plain .xlsx: no macros, no add-ins. Opens in Excel, Google Sheets, Apple Numbers and LibreOffice Calc.

Below here is why it happens

Why CHAR(160) is the wrong advice

Nearly every article recommends SUBSTITUTE(A2,CHAR(160)," "). Inside Excel it works. Outside Excel it does not, and it fails silently — the formula runs, reports success, and leaves the character in place.

Tested in LibreOffice, CODE(CHAR(160)) returns 239, not 160. So CHAR(160) is not producing a non-breaking space at all, and the substitution matches nothing. UNICHAR(160) is not available there either. If your workbook is ever opened in LibreOffice, Numbers, or by a colleague who does not use Excel, a CHAR(160)-based cleanup will report their data clean when it is not.

Putting the literal character inside the quotes needs no character-set function at all and behaves identically everywhere. That is what the workbook does.

Fix the data, not the formula

Wrapping every lookup in a cleaning chain works, but it hides the problem and slows large sheets down. Clean the column once, paste the result back over itself with Paste Special → Values, and every lookup that touches it afterwards is simple again.

XLOOKUP does not rescue you

XLOOKUP is a better function in most respects, but its default match mode is exact, so it fails on invisible characters exactly like VLOOKUP. The problem is the data, not the function.

Questions people ask

Why does my VLOOKUP fail when I can see the value?

Exact match compares strings character by character. A trailing space, a non-breaking space or a zero-width character makes two identical-looking values different, so the match fails.

Why did TRIM not fix it?

TRIM removes ordinary spaces (character 32). A non-breaking space is character 160 — a different character that TRIM leaves alone. Substitute it out before trimming.

Why is CHAR(160) not reliable?

It works in Excel but not elsewhere. In LibreOffice, CODE(CHAR(160)) returns 239, so the substitution matches nothing and silently reports the data clean. Use the literal character instead.

How do I type a non-breaking space into a formula?

Copy one out of your own data and paste it between the quotes. The free workbook already contains it, so you can lift the formula from there.

Does XLOOKUP handle this better than VLOOKUP?

No. XLOOKUP defaults to exact match and fails the same way. The problem is in the data, not in the lookup function.

Should I clean inside every formula, or clean the column once?

Clean the column once and paste the result back as values. Wrapping every lookup in a cleaning chain hides the problem and slows large workbooks down.

Related guides

Take the workbook with you

The Excel Data Cleanup Kit — a seven-tab workbook that finds all nine of these faults in a pasted column and hands back a cleaned version, a five-page PDF guide, and a short read-me. Free, no email required.

  • Excel-Data-Cleanup-Workbook-Free.xlsx — paste a column, read the diagnosis, take the cleaned output
  • Excel-Data-Survival-Guide.pdf — the eight failures, the import routine that prevents them, every formula explained
Download the kit — free 121 KB .zip · Excel & Google Sheets

Plain .xlsx: no macros, no add-ins. Opens in Excel, Google Sheets, Apple Numbers and LibreOffice Calc.