Disclosure: This is the English edition of an explainer I originally made in Japanese. It was translated with AI assistance, then reviewed and edited. Every example below uses dummy data.
Two product codes look exactly the same, but VLOOKUP returns #N/A. This post shows you how an invisible space breaks the lookup, how to spot it with LEN, and how to remove it with Find & Replace.
The received code and the master code look identical: "A-102". The stock count should come back from the master. Instead, the lookup returns #N/A — as if the code were not there at all.
(The product codes and stock counts in this post are made up.)
Why it happens
The received code has a trailing space. You cannot see it — the cell shows "A-102" either way — but to Excel the two values are different strings, and an exact-match lookup does not match them.
How to spot it: count the characters with LEN
=LEN(A2) counts the characters in the cell. The code should be 5 characters long, but the received one counts 6. That extra character is the space hiding at the end.
Check the length before you trust what the cell shows. If two values look the same but do not match, LEN is the first thing to try.
The fix: remove the spaces with Find & Replace
- Select the column with the codes.
- Open Find & Replace (Ctrl+H).
- In Find what, type a single space. Leave Replace with empty.
- Click Replace All.
Then run the lookup again. With the spaces gone, the codes match, and the stock counts come back — 40, 25, and 60 in my example.
One more thing to watch for: a full-width space (the wider space used in Japanese text) can hide in the data the same way. It looks like an ordinary gap, and it breaks the match just like a regular space does. If one is present, repeat Find & Replace with a full-width space in Find what. If a lookup still fails after Replace All, run LEN again — an extra character means a space is still there.
That fixes the space-related mismatch in this example. When an exact-match lookup fails on values that look identical, use LEN to check for extra characters.
This post is part of a small series checking what spreadsheets do to files you receive from other people — and how to open them without losing what's inside.
