Compare & combine files · 4 min read

VLOOKUP returns #N/A for IDs that look identical: what to check

Two cells can display the same digits while containing different values or types. A lookup problem needs inspection of the key, not just a change to the displayed format.

Build one controlled example before changing the whole column

Use a new sheet and format A2 and D2:D3 as Text before entering the sample IDs. Enter the names in E2:E3. Put the lookup formula below in B2. This gives you a small case where the intended match is known, separate from the production workbook.

If the small example works but the real one fails, compare one failing pair from the real data. Avoid converting an entire identifier column to numbers as a first attempt. That can collapse 00456 into 456 and make a different class of error harder to detect.

Exact-match formula in B2
=VLOOKUP(A2,$D$2:$E$3,2,FALSE)
Expected key: Text: 00456; Length: 5. Look-alike key: Text: 00456 + NBSP; Length: 6. Synthetic character comparison; NBSP is a non-breaking space, not a visible extra digit.
Illustrated example. Synthetic character comparison; NBSP is a non-breaking space, not a visible extra digit.

Check the range and match mode first

The lookup column must be the first column of the selected range. For this sample that is D, so the range starts at D2. The product name is the second column inside that range, which is why the third argument is 2. Absolute references keep the range from sliding when the formula is copied down.

FALSE requests an exact match. Do not use approximate matching to suppress an error for a product code. A nearby code is not a substitute product. If the value is genuinely absent, retain an explicit not-found state while you investigate.

SymptomCheckNext step
Many unrelated IDs failRange starts at the key columnCorrect the range and FALSE argument
Only some numeric-looking IDs failISTEXT and ISNUMBER on both keysChoose one documented key type
Keys look identical but lengths differLEN and boundary charactersFind the unexpected character
Several lookup rows have the same IDKey uniquenessResolve the lookup table before relying on results

Inspect type and length without overwriting the source

Put the diagnostic formulas in empty helper cells, referring to the failing lookup key and the candidate source key. ISTEXT distinguishes stored text from a number; changing a cell format after import is not the same operation as recovering its original text.

LEN helps expose an extra character but does not identify its meaning. If the lengths differ, examine the beginning and end of the strings. An ordinary space has character code 32 and a non-breaking space has code 160. Leave the original cells intact while comparing them.

Diagnostics for A2 and a candidate in D3
=ISTEXT(A2)
=ISNUMBER(A2)
=LEN(A2)
=ISTEXT(D3)
=LEN(D3)
=IF(LEN(A2)=0,"",UNICODE(RIGHT(A2,1)))

Clean helper keys only when the rule is justified

If exported padding spaces are definitely accidental, create cleaned text keys in separate columns. For a code that must not contain spaces, you can replace non-breaking spaces with ordinary spaces and trim outside padding. Apply the same rule to both datasets, then check whether distinct original IDs have collapsed into one cleaned value.

The example expression also normalizes repeated ordinary spaces between words because that is how TRIM works. It is therefore unsuitable for identifiers whose internal spacing is significant. Do not use cleanup as a blanket cure for every lookup error.

Helper key only if this normalization is valid for your IDs
=TRIM(SUBSTITUTE(A2,UNICHAR(160)," "))
Original values: 00456; 00456 + NBSP. Cleaned candidates: 00456; 00456. Two source values now share one candidate key. Review that collision before replacing anything.
Illustrated example. Two source values now share one candidate key. Review that collision before replacing anything.

Related help: Remove nonbreaking spaces with an explicit helper formula

Repeat the lookup against the approved keys

Arrange the cleaned lookup table so its key column is immediately to the left of the return value, and point the lookup at that range. Confirm the formerly failing row and at least one row that already worked. Then review unmatched values separately instead of replacing every error with zero.

If the raw CSV originally contained 00456 but the workbook contains only numeric 456, reimport the source as text. Padding to five digits is appropriate only if a trusted schema says every code has exactly five digits. It does not recover an unknown original identifier.

Keep the result interpretable

Record the lookup range, exact-match setting and any normalization rule with the workbook. Separate missing IDs from blank descriptions and duplicated keys. Those conditions need different corrections, even when a quick formula wrapper could make them all display an empty cell.

This guide verifies its synthetic character comparisons in Python and follows official documentation for Excel behavior. It does not claim an Excel UI test. Column Harbor can inspect raw CSV strings but does not evaluate VLOOKUP or repair workbook relationships.

Common questions

Will IFERROR fix the missing match?

No. It changes how an error is displayed. Diagnose the lookup first, then choose an explicit fallback that will not be confused with a real zero or blank value.

Should every ID be converted to text?

Choose the type required by the source schema. Numeric-looking identifiers with significant zeros or long digit sequences usually need preserved text; actual quantities have different requirements.

Can #N/A occur when the lookup value exists?

Yes, for example if the range does not start at the key column, the types differ, or an unseen character changes the value. Check the precise stored values and formula arguments.

Sources & method

Examples and diagrams use synthetic data. Application instructions follow the linked documentation; available menus and options can vary. Our sample checks do not establish behavior in every Excel or Google Sheets version. Read our AI-assisted editorial method.

Browse all field guides →