When a lookup can't find a match
Exact lookups8 min
Builds on Look up a value with VLOOKUP, Replace an error with IFERROR and Tidy text with TRIM, CLEAN, UPPER and PROPER.
The purchasing team at a hardware wholesaler in Ohio looks up the supplier on every incoming invoice. Most lines come back with a name. A few show #N/: one supplier is new to the list, one code was pasted with a space at the end, and one arrived from the accounting system as text.
How it works
An exact lookup compares the value you give it with every value in the search column, and it needs one that is the same character for character and of the same type. #N/ means "not available": none was.
Sometimes that's simply true, because the code isn't on the list yet. Then wrap the lookup in IFNA(, which returns its second argument in place of #N/ and lets every other result through.
Often the value is on the list and only looks the same. To Excel, "BX-17 " with a space at the end is a different text from "BX-17", and the text "4021" that some exports produce is a different value from the number 4021. A message would hide those rows, so fix the value you look up, inside the lookup: TRIM removes spaces at the start and end, and VALUE turns text that looks like a number into a number.
Example
A gym's front desk scans each member's card, and the card number lands in D2. The member list has card numbers in A2:A6 and names in B2:B6.
=IFNA(VLOOKUP(D2,A2:B6,2,FALSE),"Card not found")A card on the list shows the member's name, and a new card shows Card not found.
Common mistakes
- Inside IFERROR, a typo such as
VLOOKUP(, which asks for a 3rd column the table doesn't have, makes every card look unknown: VLOOKUP showsD2, A2:B6, 3, FALSE) #REF!and IFERROR hides it. IFNA lets that error show. - A code you can see still shows
#N/: compareA =LEN(with the number of characters you expect, and a longer result means hidden spaces. Look upD2) TRIM(.D2) - A number stored as text sits on the left of its cell, often with a small green triangle in the corner. Look up
VALUE(, or when it's the list that holds text, look upD2) D2&.""
In short
#N/from an exact lookup means nothing in the list is the same value: the same characters and the same type.A =IFNA(replaces onlylookup, "message") #N/, so mistakes in the formula still show.A - Clean the value you look up, inside the lookup:
TRIMfor spaces,VALUEfor numbers stored as text.
Practice
4 exercises · free, no account needed