[Excel] Error: #N/A in VLOOKUP/XLOOKUP — How to Fix It
Summary
The #N/A error in Excel’s VLOOKUP, XLOOKUP, or similar lookup functions means the formula couldn’t find a matching value. It often happens due to missing records, mismatched types (text vs number), or stray spaces. To fix it fast: ensure the lookup value exists, use exact match mode, and clean the data. The same logic applies in Excel 2016+, Microsoft 365, and Excel for Mac.
Context
Lookup functions rely on exact key matches between columns. A single invisible character or type mismatch causes #N/A. For instance, =VLOOKUP(A2, Table!A:B, 2) defaults to approximate match unless the last argument is FALSE. Similarly, XLOOKUP requires explicit match mode (0) for reliable results. In real spreadsheets with imported or user-entered data, differences in formatting or encoding are the main reason for lookup failures.
Probable Cause
- Lookup value not present. The value simply doesn’t exist in the reference column.
- Approximate match used accidentally. Default match in
VLOOKUP(TRUE) returns incorrect or#N/Aresults when data isn’t sorted. - Hidden spaces or non-printable characters. Imported text often contains leading/trailing spaces invisible in the cell display.
- Mismatched data types. Numbers stored as text (or vice versa) prevent equality comparison between lookup value and key.
Quick Fix
- Force exact match mode. Always use the last argument
FALSEinVLOOKUP, or match mode0inXLOOKUP.
=VLOOKUP(A2, Table!A:B, 2, FALSE)
=XLOOKUP(A2, Table!A:A, Table!B:B, "Not Found", 0)
- Clean spaces and hidden characters. Wrap lookup values and key ranges with
TRIM()andCLEAN().
=VLOOKUP(TRIM(A2), Table!A:B, 2, FALSE)
- Align data types. Convert both lookup value and key to text or numeric form consistently.
=VLOOKUP(VALUE(A2), Table!A:B, 2, FALSE)
- Verify existence of the value. Use
COUNTIFto confirm that the lookup value exists in the reference range.
=COUNTIF(Table!A:A, A2)
Full Example
Scenario: You imported an employee table where IDs in the lookup column are stored as text, but your lookup value is numeric. Excel returns #N/A even for existing records.
=VLOOKUP(12345, B2:C100, 2, FALSE)
#N/A
Fix: Convert the key column or lookup value to a common type.
=VLOOKUP(TEXT(12345, "0"), B2:C100, 2, FALSE)
Alternative using XLOOKUP:
=XLOOKUP(A2, B2:B100, C2:C100, "Not Found", 0)
Result: When both sides share the same format, Excel returns the correct value instead of #N/A. Cleaning and enforcing match mode prevents recurrence.
Pitfalls & Debug
- Symptom → Value exists but formula still returns
#N/A. Fix → Confirm there are no spaces:=LEN(A2)and compare lengths. - Symptom →
VLOOKUPworks only for some rows. Fix → Convert entire lookup column to consistent format (text or number). - Symptom → Imported CSV data breaks lookups. Fix → Apply
Text to Columnsand choose the correct data type. - Symptom → Using approximate match on unsorted data. Fix → Always set fourth argument to
FALSE. - Symptom → Power Query merge returns null. Fix → Ensure both tables have aligned data types before merging.
Validation & Next Steps
After corrections, test the lookup with a value you know exists and verify matches using helper checks:
=COUNTIF(Table!A:A, A2)
Ensure the function returns a count ≥1. Convert columns consistently with VALUE() or TEXT() as needed. If lookups span multiple sheets or imported data, clean with TRIM() and CLEAN() before applying formulas.
Sources
Tool/Excel, OS/Cross-platform, Topic/Lookup & Formula Errors