Excel XLOOKUP
XLOOKUP searches one column for a value and returns the matching item from another column, in either direction.
A stock controller has a code on a purchase order and needs the product name and price from the catalog. Older formulas break if a column is inserted and cannot look to the left. XLOOKUP points at the exact columns involved and lets you write your own message when a code is missing.
Practice it nowHow to write it
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])- lookup_value
- What you are searching for.
- lookup_array
- The column to search.
- return_array
- The column holding the answer.
- if_not_found
- Optional text to show when nothing matches.
- match_mode
- Optional. 0 is exact, and is the default.
- search_mode
- Optional. -1 searches from the bottom up.
Watch it work
Examples
Which product is P-103?
=XLOOKUP("P-103",A2:A6,B2:B6)LampFind the code in column A and return the same row from column B.
Handle a code that does not exist
=XLOOKUP("P-999",A2:A6,B2:B6,"Not found")Not foundThe fourth argument replaces the #N/A error.
Look to the left
=XLOOKUP("Shelf",B2:B6,A2:A6)P-104The answer column sits before the search column, which VLOOKUP cannot do.
Your turn
Return the Price of the Cabinet. Type your formula in F2.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | SKU | Product | Price | Stock | ||
| 2 | P-101 | Desk | 240 | 12 | ||
| 3 | P-102 | Chair | 95 | 40 | ||
| 4 | P-103 | Lamp | 35 | 0 | ||
| 5 | P-104 | Shelf | 120 | 7 | ||
| 6 | P-105 | Cabinet | 310 | 3 | ||
| 7 |
Common mistakes
Getting #N/A for a value you can see.
One side may be text and the other a number, or there may be a stray space.
Sending this to someone on Excel 2019 or older.
XLOOKUP needs Excel 2021 or Microsoft 365. Use INDEX and MATCH for older versions.
Good to know
- Return several columns at once by making the return array wider, such as B2:C6.
- Use search mode -1 to find the most recent entry in a log.
- XLOOKUP or VLOOKUP? VLOOKUP counts columns from the left and defaults to approximate match. XLOOKUP names the return column and defaults to exact match.
Excelio