How to Use XLOOKUP in Google Sheets (Examples, Modes, and Error Fixes)


Abstract flat illustration of a white spreadsheet grid with a teal search cell on the right side, a two-way teal arrow sweeping left across a highlighted row, and the matched cells connected to a clean result card

The most expensive VLOOKUP failure I’ve ever cleaned up never produced an error. Someone inserted a “Supplier” column into a shared price list in March, and every VLOOKUP pointing at that table silently shifted one column — the sheet spent weeks quoting stock levels as if they were prices. No red triangles, no complaints. XLOOKUP exists because of failures exactly like that one: it replaces VLOOKUP’s fragile column-counting with two explicit ranges — one to search, one to return — and it defaults to an exact match instead of hoping you remembered the fourth argument.

This guide builds a working XLOOKUP from the same price-list example as our VLOOKUP guide, explains the match and search modes that replace VLOOKUP’s TRUE/FALSE switch, covers the three things XLOOKUP does that VLOOKUP can’t, and ends with the fix for every error it can throw.

What XLOOKUP Actually Does

VLOOKUP is a menu read in one direction: find the dish in the left column, read the price to its right. XLOOKUP drops the menu rule. You name the column to search and the column to read from as two separate ranges, in whichever order they happen to sit — the same way a contacts list lets you find a number from a name or a name from a number. The position where the match lands in the search range is the position it reads from the result range. Nothing is counted, and nothing has to be on the left.

The syntax:

=XLOOKUP(search_key, lookup_range, result_range, [missing_value], [match_mode], [search_mode])

ArgumentWhat it isExample
search_keyThe value to find — a literal or a cell reference”SKU-103” or F2
lookup_rangeThe single column (or row) to searchB2:B6
result_rangeThe range to read the answer from; must be the same size as lookup_rangeC2:C6
missing_valueWhat to return when there’s no match; defaults to #N/A”Not in list”
match_mode0 = exact (default), -1 = exact or next smaller, 1 = exact or next larger, 2 = wildcard0
search_mode1 = first to last (default), -1 = last to first, 2 / -2 = binary search on sorted data1
Tip: Only the first three arguments are required, and the defaults are the safe ones — exact match, first match wins, an honest #N/A when the key is missing. VLOOKUP's classic trap, silently falling back to approximate matching, is designed out rather than documented around.

Step by Step: Your First XLOOKUP

Same sheet as the VLOOKUP guide: product names in column A, SKUs in column B, prices in column C, stock levels in column D — data in rows 2 through 6. The SKU you care about sits in cell F2, and you want its price in G2.

  1. Click the cell where the answer should appear — G2 here.
  2. Type =XLOOKUP(F2, B2:B6, C2:C6).
  3. Press Enter. The price for that SKU appears.

Why those exact pieces:

  • The lookup range is just the SKU column — XLOOKUP searches one column, not a whole table, so there’s no “first column of the range” rule to satisfy.
  • The result range is just the price column, the same height as the lookup range. Position 3 in B is position 3 in C — that’s the entire mechanism.
  • There’s no fourth argument because exact match is the default. Compare the VLOOKUP version, =VLOOKUP(F2, B2:D6, 2, FALSE), where forgetting FALSE changes the meaning of the formula.

Nothing in the XLOOKUP version counts columns, so inserting a column between the SKUs and the prices next month changes nothing — Sheets adjusts both range references, and the formula still reads prices. That single difference is why XLOOKUP survives edits that quietly corrupt VLOOKUPs.

Tip: Dragging the formula down a column? The locking habit carries over from VLOOKUP: press F4 to make the ranges absolute — $B$2:$B$6 — or use whole-column references like B:B paired with C:C, which are always the same size as each other.

Match Modes and Search Modes: The Two Dials

VLOOKUP squeezed two different questions into one TRUE/FALSE argument. XLOOKUP splits them into two dials that each answer one question: what counts as a match, and where do I start looking.

Match mode — what counts as a match. Mode 0 (the default) demands an identical value. Modes -1 and 1 are the band-matching tools VLOOKUP’s TRUE was for, except they say which direction to fall: -1 takes the exact value or the next one smaller, 1 takes the exact value or the next one larger. For discount tiers — spend 0 earns 0%, 100 earns 5%, 250 earns 10%, 500 earns 15% — a $320 order should land on the 250 tier:

=XLOOKUP(320, A2:A5, B2:B5, , -1) returns 10%, because 250 is the largest tier boundary that 320 has passed. (The empty slot is the skipped missing_value argument.) Mode 2 turns on wildcards, covered in the edge cases below.

Search mode — where the search starts. Mode 1 scans top to bottom and returns the first match. Mode -1 scans bottom to top and returns the last match, which turns a sales log into a “most recent” lookup with no sorting and no helper columns:

=XLOOKUP(“SKU-103”, A:A, C:C, “No sales yet”, 0, -1) finds the most recent row for that SKU and returns its price. Modes 2 and -2 are binary searches for very large sorted ranges — fast, but they return confidently wrong answers on unsorted data, the same footgun as VLOOKUP’s TRUE wearing a different argument’s clothes.

Three Things XLOOKUP Does That VLOOKUP Can’t

1. It looks left. Because the two ranges are independent, the result can sit anywhere — including left of the search column. Given a SKU, return the product name stored one column to its left:

=XLOOKUP(F2, B2:B6, A2:A6) — a formula VLOOKUP simply cannot express; before XLOOKUP this needed INDEX/MATCH.

2. It returns several columns at once. Make the result range wider than one column and XLOOKUP returns the whole slice of that row, spilling into the neighboring cells:

=XLOOKUP(F2, B2:B6, A2:D6) returns the name, SKU, price, and stock level in one formula, in four cells. Keep the cells beside the formula empty — a blocked spill is one of the errors below.

3. It fails politely without a wrapper. VLOOKUP needs an IFERROR jacket to replace #N/A with a friendly message. XLOOKUP’s fourth argument does it natively:

=XLOOKUP(F2, B2:B6, C2:C6, “Not in list”)

XLOOKUP vs. VLOOKUP

XLOOKUPVLOOKUP
Default matchExactApproximate (the trap)
Lookup directionAny — result can be left of the keyRight only
Column countingNone — two explicit rangesHardcoded index number
Missing keyBuilt-in missing_value argument#N/A unless wrapped in IFERROR
Multiple results per formulaYes — multi-column result range spillsNo — one cell per formula
Last matchYes — search_mode -1No
CompatibilityGoogle Sheets; Excel for Microsoft 365 and Excel 2021+Everywhere, including old Excel

The honest verdict mirrors the VLOOKUP guide’s: keep reading VLOOKUP, because decades of existing sheets are full of it, but write XLOOKUP for anything new — right up until a file has to be shared with someone on an old copy of Excel, where VLOOKUP (or INDEX/MATCH) is still the safe choice.

Every Error XLOOKUP Can Throw

ErrorWhat it meansFix
#N/AThe key wasn’t found and no missing_value was givenAdd the fourth argument, or fix the key (typos, spaces, text-numbers)
#VALUE!The lookup and result ranges are different sizesMake both ranges the same height (or width, for rows)
#REF!A multi-column result couldn’t spill — the cells beside the formula aren’t emptyClear the cells the result needs to expand into
Wrong value, no errorBand modes on unsorted tiers, duplicate keys, or wildcard mode catching extrasCheck match_mode and search_mode; clean the duplicates

#VALUE!: the ranges don’t match in size

This is XLOOKUP’s signature error and the one VLOOKUP users haven’t met before. =XLOOKUP(F2, B2:B6, C2:C5) searches five rows but reads from four, and Sheets refuses: positions can’t line up. The fix is mechanical — recount both ranges and make them equal. Whole-column pairs (B:B with C:C) can never mismatch, which is one more reason to prefer them for tables that grow.

#N/A: the key wasn’t found

If you didn’t supply a missing_value, #N/A is XLOOKUP working as designed — it’s the formula saying “not here.” When you expected a match, the suspects are the same three as VLOOKUP’s: a typo, invisible trailing spaces (fix with =TRIM() on the source), and numbers stored as text that will never equal the numeric version of themselves.

Wrong record, no error: duplicate keys

With duplicates in the lookup column, the default search_mode returns the first match, top to bottom. Sometimes that’s the bug (an outdated price row sitting above the current one) and sometimes the last row is what you actually wanted — in which case search_mode -1 is the fix, used deliberately. If neither first nor last is reliably right, the real problem is the duplicates themselves; the cleanup routes in removing duplicates in Google Sheets apply unchanged.

The Limitations Worth Knowing

  • Compatibility ends at old Excel. XLOOKUP lives in Google Sheets and modern Excel. Download the file for a colleague running Excel 2016 and every XLOOKUP comes back as #NAME?. VLOOKUP survives the trip.
  • One match only — first or last. There is no mode that returns every matching row. When you need all of them, that’s FILTER’s job, not a lookup’s.
  • The lookup range is a single row or column. Searching a grid by row and column at once needs two nested XLOOKUPs (one to fetch the row, one to pick from it) or INDEX/MATCH.
  • Binary modes demand sorted data. Search modes 2 and -2 assume the lookup range is sorted their way. Skip them unless a plain scan is measurably slow.

Edge Cases Worth Knowing

  • Wildcards are opt-in. =XLOOKUP(“Smith*”, A2:A20, B2:B20, , 2) matches the first Smith-anything — but only because match_mode 2 is set. Under the default mode 0, the asterisk is a literal character and matches nothing real.
  • Case sensitivity: still none. “smith” matches “Smith”, exactly as with VLOOKUP. Build an =EXACT() helper column if your data truly needs the distinction.
  • Horizontal tables just work. Pass a single-row lookup range and a single-row result range — =XLOOKUP(“Q3”, B1:E1, B2:E2) — and there’s no separate HLOOKUP to learn.
  • Tables that grow on their own. If the lookup table is fed by something live — responses landing from a linked Google Form, say — whole-column references keep the formula correct forever without an edit, and they sidestep the #VALUE! size mismatch entirely.

Frequently Asked Questions

Is XLOOKUP better than VLOOKUP?

For anything you’re writing today, yes: exact match by default, no column counting, either direction, a built-in not-found message. VLOOKUP still matters because existing sheets are full of it and because it works in every spreadsheet program ever shipped — including the old Excel installs XLOOKUP can’t run in.

Why does my XLOOKUP return #VALUE!?

Almost always mismatched ranges: the lookup range and the result range cover a different number of rows (or columns). B2:B6 against C2:C5 is the classic — one range was extended and the other wasn’t. Equalize them, or switch both to whole columns.

Can XLOOKUP return multiple matches for one key?

No. It returns one match — the first (search_mode 1) or the last (search_mode -1). To pull every matching row into a list, use FILTER with the same condition you’d have given the lookup.

Does XLOOKUP work in Excel too?

Yes, in Excel for Microsoft 365 and Excel 2021 or later, with the same argument order as Google Sheets — formulas move between the two without translation. In Excel 2019 and older it returns #NAME?, because the function doesn’t exist there.

XLOOKUP or INDEX/MATCH — which should I use?

INDEX/MATCH still wins for two-dimensional lookups (row and column criteria) and for files that must survive old software. For the everyday one-key lookup, XLOOKUP says the same thing in one function instead of two nested ones, and its defaults are harder to get wrong.


Sources:

Written by

FazTest Editorial Team

The FazTest editorial team writes practical guides for the software you use every day — spreadsheets, documents, design tools, and automation. Every guide follows steps we completed ourselves first, verified against the current version of the tool — not marketing materials.

SpreadsheetsDocuments & NotesDesign & PresentationWorkflow & Automation