XLOOKUP in Excel: examples and practice

XLOOKUP finds a value in one column and gives back the value from the same row in a different column. For example, =XLOOKUP("Mint",A2:A6,B2:B6) finds Mint in A2:A6 and gives back its price from B2:B6.

Syntax

=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
lookup_value
The value to find, for example a product name or a cell like E2.
lookup_array
The column (or row) where Excel looks for the value.
return_array
The column with the result. It must have the same size as lookup_array.
if_not_found
Optional. The result when Excel does not find the value. Without it, you get #N/A.
match_mode
Optional. 0 is an exact match (default). -1 takes the next smaller value, 1 the next larger value.
search_mode
Optional. 1 searches from the top (default), -1 from the bottom.

Examples

Example data

ABC
1FlavorPriceStock
2Vanilla$2.5040
3Chocolate$2.7525
4Mint$3.0012
5Mango$3.250
6Pistachio$3.508
FormulaResultWhat it does
=XLOOKUP("Mint",A2:A6,B2:B6)$3.00Finds Mint in the Flavor column and gives back the price from the same row.
=XLOOKUP("Mango",A2:A6,C2:C6)0The same search, but the result comes from the Stock column.
=XLOOKUP("Lemon",A2:A6,B2:B6,"Not on the list")Not on the listLemon is not in the list. Argument 4 gives a clear message instead of #N/A.

Try it

In cell F2, use XLOOKUP to find the price of the flavor in E2.

Show the solution

=XLOOKUP(E2,A2:A6,B2:B6) → $3.50

Common mistakes

#N/A because of a space

"Mint " with a space at the end is not the same as "Mint". Remove extra spaces with TRIM, or use argument 4 to show a message.

Ranges of different sizes

A2:A6 and B2:B5 do not have the same number of rows. Excel shows #VALUE!. Use ranges with the same rows.

Ranges move when you copy the formula

When you fill the formula down, A2:A6 becomes A3:A7. Lock the ranges with $ (press F4 (Mac: fn+F4)): $A$2:$A$6.

Mia, owns Polar Scoops, an ice cream shop

Practice this in a story

A short lesson from a real job. We show you each step, then you do it yourself.

Prices for Saturday · Module 1 · Excel Basics · 6 min

Saturday was a busy day. Eight orders have no price. Mia has a price list, but no time. You help her.

Practice this in a story

More lessons with XLOOKUP

Related functions