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 now

How 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

F2fx 
ABCDEFG
1SKUProductPriceStock
2P-101Desk24012
3P-102Chair9540
4P-103Lamp350
5P-104Shelf1207
6P-105Cabinet3103
7
1

Find the code in column A and return the same row from column B.

Examples

Which product is P-103?

=XLOOKUP("P-103",A2:A6,B2:B6)Lamp

Find 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 found

The fourth argument replaces the #N/A error.

Look to the left

=XLOOKUP("Shelf",B2:B6,A2:A6)P-104

The answer column sits before the search column, which VLOOKUP cannot do.

Your turn

Return the Price of the Cabinet. Type your formula in F2.

ABCDEF
1SKUProductPriceStock
2P-101Desk24012
3P-102Chair9540
4P-103Lamp350
5P-104Shelf1207
6P-105Cabinet3103
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.