FxFormula Drills

XLOOKUP vs VLOOKUP

Use XLOOKUP when everyone opening the file has Excel 2021, Excel 2024, Microsoft 365, or Google Sheets. It looks up an exact match by default, can search any column, and can return a phrase you choose when nothing matches. Use VLOOKUP when the workbook must also open in Excel 2019 or earlier. VLOOKUP only searches the first column of a block and, unless you pass FALSE, it does an approximate match.

Syntax

XLOOKUP

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

lookup_array is the column or row you search. return_array is the column or row you want back. They do not have to sit inside one rectangle, and the return column can be to the left of the search column. match_mode 0, the default, is an exact match. if_not_found is used only when there is no match.

VLOOKUP

VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])

table_array must start with the column you search. col_index_num counts from that first column, and 1 means the search column itself. range_lookup FALSE or 0 forces an exact match. TRUE, or leaving the argument out, asks for an approximate match and expects the first column to be sorted ascending.

Comparison

QuestionXLOOKUPVLOOKUP
Default matchExactApproximate if you omit the fourth argument
Where it can lookAny column or row, including to the leftOnly down the first column of the table
What a missing item returnsThe if_not_found argument, or #N/A if you omit it#N/A for an exact match that fails
Inserting a columnStill correct, because the return range is its own argumentThe column index can point at the wrong field
Approximate bracketsmatch_mode -1 for the next smaller itemFourth argument TRUE, first column sorted ascending
VersionsExcel 2021, Excel 2024, Microsoft 365, Excel for the web, Google SheetsExcel and Google Sheets, including versions before 2021

Worked examples

Exact price for Book

The price list has the product in column A and the price in column B. E2 holds the product to find. Both formulas return the price on Book's row.

Price list. Book costs 12.
RowABCDE
1ProductPriceQtyFind
2Pen1.54Book
3Book122
4Lamp241
  • =XLOOKUP(E2,A2:A4,B2:B4) → 12
  • =VLOOKUP(E2,A2:C4,2,FALSE) → 12

XLOOKUP searches A2:A4 and returns the cell on the same row of B2:B4. VLOOKUP searches the first column of A2:C4 and returns column 2 of that block, which is also the price. FALSE is what makes VLOOKUP demand an exact product name. Drop FALSE and you are no longer asking the same question.

A product that is not on the list

Desk is not in the price list. XLOOKUP can show a word you choose. VLOOKUP with FALSE returns the #N/A error, which IFNA can replace. IFNA leaves other errors alone.

Same price list. The lookup value is the word Desk, which is not a product.
RowABCDE
1ProductPriceQtyFind
2Pen1.54Book
3Book122
4Lamp241
  • =XLOOKUP("Desk",A2:A4,B2:B4,"Missing") → Missing
  • =VLOOKUP("Desk",A2:B4,2,FALSE) → #N/A
  • =IFNA(VLOOKUP("Desk",A2:B4,2,FALSE),"Missing") → Missing

The fourth XLOOKUP argument is only for a failed match. It is the closest equivalent of wrapping VLOOKUP in IFNA. IFERROR would also hide #N/A, but it would hide a typo such as #NAME? or a broken range as well. Prefer IFNA when the only failure you want to translate is a missing key.

Two Pens, and you want the last one

XLOOKUP's sixth argument chooses the search direction. 1, the default, starts at the top. -1 starts at the bottom. VLOOKUP always starts at the top and stops at the first exact match.

Pen appears twice. The later row has the price you want.
RowAB
1ProductPrice
2Pen1
3Pen9
  • =XLOOKUP("Pen",A2:A3,B2:B3) → 1
  • =XLOOKUP("Pen",A2:A3,B2:B3,,0,-1) → 9

The default call returns 1 from the first Pen. The call with search_mode -1 returns 9 from the last Pen. match_mode stays 0 so the match is still exact. Use this when a list is an event log and the latest row for an id is the one that counts.

When to use which

Choose XLOOKUP for a new workbook

New models, class files, and Google Sheets should start with XLOOKUP. The arguments say which column you search and which column you return, so inserting a column between them does not silently change the answer. Exact match is the default, which is what a product code, an employee id, or an email lookup wants.

Keep VLOOKUP when the file has a long life

If a client, a government template, or a classmate may open the file in Excel 2016 or 2019, VLOOKUP still runs and XLOOKUP shows #NAME?. Write the VLOOKUP with FALSE unless you have sorted numeric brackets and you mean an approximate match. Pair it with IFNA when a missing key should show a blank or a label instead of an error.

Use approximate match only for sorted brackets

Commission tiers, tax bands, and shipping cutoffs are the honest use of VLOOKUP's TRUE and of XLOOKUP match_mode -1. The lookup column has to be sorted ascending. An id column is not that kind of list. The practice page walks a numeric bracket with both functions.

Common mistakes

Leaving VLOOKUP's fourth argument out

Omitted means TRUE. On a product list that is not sorted, an approximate match can return a neighbor's price or #N/A. For names and ids, type FALSE or 0 every time.

Counting columns from the wrong edge

col_index_num is not the worksheet column letter. It is the position inside table_array. If the table starts in column C, the first column of the table is index 1 even though the sheet calls it C.

Searching a column that is not the first column

VLOOKUP cannot look to the left. If prices are in B and the name you want is in A, switching the index number does not fix it. Use XLOOKUP or INDEX/MATCH, which take the search range and the return range separately.

Wrapping every lookup in IFERROR

IFERROR hides #REF!, #VALUE!, and #NAME? as well as a genuine miss. While you are building the formula, let the error show. Add IFNA, or XLOOKUP's if_not_found, after the lookup itself is right.

Versions and compatibility

XLOOKUP is in Excel 2021, Excel 2024, Microsoft 365, and Excel for the web. It is not in Excel 2019 or earlier, where the formula returns #NAME?. Google Sheets has XLOOKUP as well.

VLOOKUP and HLOOKUP are in current Excel, in older Excel, and in Google Sheets. IFNA, used above to label a missed VLOOKUP, is in Excel 2013 and later and in Google Sheets. Excel 2007 through 2010 can use IFERROR for the same label, with the caveat that IFERROR also catches errors that are not a missing key.

Argument separators in these examples are commas, which is correct for a United States locale in both Excel and Google Sheets. Locales that use semicolons need semicolons between arguments. The functions themselves do not change.

Practice on Formula Drills

Free drills are open with no account. Premium drills show the problem to everyone and grade the sheet for subscribers.

Free exercises

Premium exercises

Function pages

FAQ

Is XLOOKUP faster than VLOOKUP?

On a short list the difference does not matter. The reason to switch is the default exact match, the separate return range, and a built-in result for a miss. Speed is not the decision.

Does XLOOKUP replace HLOOKUP too?

Yes. Point lookup_array at a header row and return_array at the row underneath. You do not need a different function for a horizontal table. HLOOKUP is still what older files use when the labels run across.

Why does my VLOOKUP return the wrong price when the product is there?

The usual cause is an approximate match. Add FALSE as the fourth argument. The next place to look is the column index: it counts columns inside the table, starting at 1 for the column you search.

Can XLOOKUP return two columns at once?

In Excel 2021, Excel 2024, Microsoft 365, and Google Sheets, a return range that is two columns wide spills both values. The worked pattern of one formula per column is on the multiple-column page, because that form also runs in the Formula Drills checker.