ShareYourGroupShareYourGroupGoogle Sheets

Lookup

XLOOKUP function in Google Sheets

XLOOKUP finds a value in one range and returns the matching item from another, in any direction.

XLOOKUP is the newer lookup function, added to Google Sheets in 2022. It does what VLOOKUP does with fewer traps: exact match by default, any direction, and a built-in answer for a missing value.

Syntax

=XLOOKUP(search_key, lookup_range, result_range, [missing_value], [match_mode], [search_mode])
ArgumentWhat it is
search_keyThe value to look for.
lookup_rangeThe single row or column to search.
result_rangeThe row or column to return from, the same size as the lookup range.
missing_valueWhat to show if nothing is found. Without it the result is #N/A.
match_mode0 exact (the default), 1 exact or next larger, -1 exact or next smaller, 2 wildcard.
search_mode1 from the first item (the default), -1 from the last.

Examples

Sample sheet: A small price list with item codes. The table is sorted by code.
ABCDE
1CodeItemCategoryPriceStock
2A101Basmati Rice 5 kgGrocery65040
3A102Toor Dal 1 kgGrocery16075
4B201NotebookStationery60300
5B202Ball PenStationery100
6C301LED BulbElectronics110200
7C302Power BankElectronics129918
8D401Steel BottleHome45055
Sample sheet: Twelve sales made by four salespeople in three regions.
ABCDEF
1DateSalespersonRegionProductUnitsAmount
205-Jan-2026AshaNorthNotebook201200
312-Jan-2026RaviSouthPen50500
420-Jan-2026MeenaNorthBag43000
502-Feb-2026AshaEastPen30300
614-Feb-2026KabirSouthNotebook15900
728-Feb-2026RaviNorthBag21500
803-Mar-2026MeenaEastNotebook402400
915-Mar-2026AshaNorthBag32250
1022-Mar-2026KabirSouthPen60600
1101-Apr-2026RaviEastNotebook251500
1218-Apr-2026MeenaNorthPen80800
1306-May-2026AshaSouthBag53750

How it works

XLOOKUP takes two separate ranges: one to search, one to answer from. It finds the position of the key in the first and returns the item at the same position in the second. There is no column number, and it does not matter which range is on the left.

Compared with VLOOKUP

VLOOKUPXLOOKUP
Default matchsorted (approximate)exact
Directionkey in the first column, answer to its rightany
Insert a columnmay break the indexno effect
Missing keyneeds IFNAfourth argument
Last matchnosearch from the end

Match and search modes

Match mode -1 returns the next smaller item when there is no exact match, and 1 the next larger. Unlike VLOOKUP's sorted mode, the data need not be sorted. Mode 2 allows the wildcards * and ?.

Search mode -1 searches from the last item upwards, which returns the latest entry in a list kept in date order, as the last example shows.

Returning a whole row

If the result range is several columns wide, XLOOKUP returns the whole row of results across the cells to the right. One formula can bring back the name, the category and the price for a code.

Across a whole column

Unlike VLOOKUP, XLOOKUP is awkward to expand with ARRAYFORMULA when it must return one value per row for a column of keys. It works in simple cases, =ARRAYFORMULA(XLOOKUP(A2:A10, Codes, Names)), but if you need a self-filling column, VLOOKUP inside ARRAYFORMULA is the well-trodden path.

When to use which

Common mistakes

In Excel

XLOOKUP exists in Excel 2021 and Microsoft 365 with the same six arguments, under slightly different names. Formulas carry over unchanged.

Related functions

The results on this page were worked out by us from the sample sheet; they were not produced by a script running Google Sheets. If Sheets shows you something different, please tell us.

This is an independent help site. It is not connected with or approved by Google. Google Sheets is a trademark of Google LLC, named here only to say which program a formula is for. The people and figures in the sample sheets are made up.