XLOOKUP in Excel: what it does and how to use it

XLOOKUP takes a value, looks for it in one column, and returns the matching item from another. Unlike VLOOKUP the two columns can be anywhere, in any order, and you can say what should appear when nothing matches.

Syntax

XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found])

When to use it

Use it for any lookup at all if your Excel has it. It replaces both VLOOKUP and the INDEX and MATCH pairing, and it is exact by default, so the commonest lookup mistake is simply not possible.

What trips people up

It needs Microsoft 365 or Excel 2021. On anything older the formula comes back as #NAME?, and VLOOKUP or INDEX with MATCH is the way round it.

Watch it built, step by step

Questions

What do the optional arguments do?

The fourth sets what appears when nothing matches, such as "Not found". The fifth sets the match type: 0 for exact, which is the default, -1 or 1 for the next smaller or larger value, 2 for wildcards. The sixth sets the direction, and -1 searches from the bottom up, which finds the most recent entry.

Can XLOOKUP return more than one column?

Yes. Give it a return range several columns wide and the results spill across into the neighbouring cells.

Does XLOOKUP work in Google Sheets?

Yes. Google Sheets has XLOOKUP with the same arguments, so a formula written for Excel works there unchanged.

Related functions

Settings: separator, Excel version

Argument separator

Set by your computer's language, not by the file. A frequent cause of a correct-looking formula being rejected.

Excel version

XLOOKUP, IFS, TEXTBEFORE and TEXTJOIN need Microsoft 365 or 2021; older versions return #NAME? instead. Choosing the older one switches every walkthrough to a formula that works there.