XLOOKUP Formula Generator
Fill in what you are looking for and where to find it, and get a working XLOOKUP formula with the fallback that stops it returning #N/A.
When to use XLOOKUP
- Pulling a price, region or name out of a reference table
- Replacing a VLOOKUP that breaks whenever a column is inserted
- Returning a value from a column to the left of the one you match on
How the formula works
Taking the example on this page apart, piece by piece:
=XLOOKUP(A2,$F$2:$F$5,$G$2:$G$5,"Not Found")
A2The value to look for: whatever is in A2.
$F$2:$F$5Where to look for it. XLOOKUP searches this range for an exact match.
$G$2:$G$5What to return: the value from this range on the same row as the match.
"Not Found"What to show when there is no match, instead of #N/A.
Where it goes wrong
Leaving the ranges unlocked
It works on the first row, then shifts when filled down and starts returning #N/A for the earliest records. Lock them with $ signs.
Lookup and return ranges of different heights
XLOOKUP returns #VALUE! when the two arrays do not cover the same number of rows. This is invisible until it runs.
Skipping the fourth argument
Without an if-not-found value, a missing match shows #N/A. A readable message is almost always better in a report.
Practise it
A generator gives you the formula. These give you the reason it works — and tell you which assumption broke when it does not.
- Look up a customer's region with XLOOKUP · intermediate
- Handle missing lookups gracefully · advanced
- Lock ranges so a lookup survives fill-down · advanced