What is the XLOOKUP function?
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])XLOOKUP finds a value in one range (lookup_array) and returns the value at the same position in another range (return_array). Because the two ranges are separate, the return column can be to the left or the right.
It defaults to an exact match, lets you choose what to show instead of #N/A, and can search from the bottom up to find the last match.
XLOOKUP is available in Microsoft 365 and Excel 2021 or later. It is not available in Excel 2019 or earlier.
Arguments
- lookup_value
- The value to find.
- lookup_array
- The range to search, usually a single column.
- return_array
- The range to return a value from. It must have the same number of rows as lookup_array.
- if_not_found
- Optional. Returned when there is no match. If omitted, the result is #N/A.
- match_mode
- 0 exact match (default), -1 exact or next smaller, 1 exact or next larger, 2 wildcard match with * and ?.
- search_mode
- 1 searches from first to last (default). -1 searches from last to first, which finds the last match.
XLOOKUP examples
Example 1. Return a price by product name
=XLOOKUP("Eggs", B2:B9, C2:C9)Finds Eggs in column B and returns 6900 from the same row of column C.
Example 2. Return a value from the left
=XLOOKUP("Eggs", B2:B9, A2:A9)The return range is to the left of the lookup range. The result is P004. VLOOKUP cannot do this.
Example 3. Show a message instead of #N/A
=XLOOKUP("Pear", B2:B9, C2:C9, "Not found")Pear is not in the list, so the formula returns "Not found" instead of an error, without wrapping it in IFERROR.
Common mistakes
Ranges of different sizes
If lookup_array is B2:B9 and return_array is C2:C8, XLOOKUP returns #VALUE!. Both must cover the same rows.
Using it in an older Excel
Files that use XLOOKUP show #NAME? in Excel 2019 or earlier. Use INDEX/MATCH if the file will be opened in older versions.
Expecting wildcards in exact mode
* and ? are treated as wildcards only when match_mode is 2.
FAQ
- Is XLOOKUP better than VLOOKUP?
- It is more flexible: exact match by default, any return direction, and a built-in fallback. VLOOKUP still matters when files must work in older Excel.
- How do I find the last match?
- Set search_mode to -1 so the search starts at the bottom.