Skip to content

All-Access: every lesson, no ads. $8.25€8.25US$8.25$4.08US$4.08$2.41US$2.41₹224.91MX$74.91 a month, billed yearly. Free to start. Cancel any time

See plans
All-Access, no ads: every lesson, course and template. $8.25€8.25US$8.25$4.08US$4.08$2.41US$2.41₹224.91MX$74.91 a month. + GST at checkoutSee the plans →

Functions

XLOOKUP Excel: How to Use It, With Examples and Fixes

By the LogicExcel Editorial Team21 min read4,112 wordsPractice this

XLOOKUP finds a value in one range and returns the matching item from another range. To get the price for the SKU in G2, type =XLOOKUP(G2,A2:A7,D2:D7). Excel searches A2:A7 for the SKU and returns the entry in the same position of D2:D7. It matches exactly by default, can look left or right, and takes a custom message for items it cannot find.

Try this now

XLOOKUP is the modern way to look up a value. Find the price of the product in D2 by looking it up in the product list A2:A5 and returning from the price column B2:B5. Put the answer in E2.
ABCDE
1ProductPriceLookupResult
2Apple30Cherry
3Banana20
4Cherry50
5Date80
E2fx

Continue the full lesson →

Ready to practice?

Apply what you just learned with interactive exercises.

Start Lesson 63

This guide shows how to use the XLOOKUP function in Excel, from the first formula to two-way lookups. You get every argument explained, ten worked examples, most of them on one product sheet, a comparison with VLOOKUP and INDEX MATCH, the version rules, the errors you will meet and the exact mistakes learners make on our practice screens.

TL;DR

  • The pattern is =XLOOKUP(lookup_value, lookup_array, return_array). The first range is what you search, the second is what you get back.
  • Exact match is the default, so you never type a trailing FALSE or 0 the way VLOOKUP needs.
  • Use the fourth argument to replace #N/A with your own text, and leave two commas before the match mode when you skip it: ,,-1.
  • XLOOKUP can return a value to the left of the search column, a whole row, or several columns at once.
  • It needs Microsoft 365, Excel 2021 or later, or Excel for the web. Excel 2019 and older do not have it.
  • Numbers stored as text, stray spaces and a return range that is one row or column off cause most wrong answers.

Table of Contents

The sample data used in every example

Every example below runs on one small product sheet for an office supplier. Type it into a blank workbook starting at A1 so the cell references match.

RowABCDE
1SKUProductCategoryUnit priceStock
2K-100Desk lampLighting24914
3K-101Ergonomic chairFurniture18506
4K-102Monitor armAccessories6200
5K-103Standing deskFurniture42003
6K-104USB hubAccessories38025
7K-105Desk lampLighting2799
Two details matter later. "Desk lamp" appears twice because K-105 is a revised model, which lets us test first match against last match. And K-102 has a stock of 0, which shows how a zero behaves.

An order list sits to the right, in G1:H4.

RowGH
1Order SKUQty
2K-1032
3K-1005
4K-9991
K-999 is deliberately not in the product list. A few examples use two extra small tables, and each one is printed where it is used.

XLOOKUP syntax and arguments

The full pattern has six arguments, three required and three optional:

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

ArgumentRequiredWhat it does
lookup_valueYesThe thing you are looking for: a cell, a typed value in quotes, or a number.
lookup_arrayYesThe single row or column to search.
return_arrayYesThe range to return from. It must be the same height as lookup_array for a column search, or the same width for a row search.
if_not_foundNoWhat to show when nothing matches. Without it you get #N/A.
match_modeNoHow strictly to match. 0 is exact, the default.
search_modeNoWhich direction to search, or whether to use a binary search. 1 is first to last, the default.
Read the first three as a sentence: look for this, in here, and give me back the matching entry from there. The lookup range and the return range are separate, so you never count columns. That one design choice removes the most common VLOOKUP mistake.

XLOOKUP ignores upper and lower case. "k-103" finds K-103. It returns the first match it meets unless you change the search mode.

XLOOKUP examples from simple to advanced

Each case below uses the sample data and gives the result you should see.

How to do XLOOKUP for a basic price lookup

The basic job: the order list says K-103 and you want its unit price.

=XLOOKUP(G2,A2:A7,D2:D7)

Excel finds K-103 in A2:A7. It sits in the fourth position (A5), so the formula returns the fourth entry of D2:D7, which is 4200. If you are asking how to use XLOOKUP in Excel for the first time, this single pattern covers most of what you will do with it.

How to show a message instead of #N/A

SKU K-999 is not in the list. Without a fourth argument the formula returns #N/A:

=XLOOKUP("K-999",A2:A7,D2:D7)

Add your own text as the fourth argument and the sheet stays readable:

=XLOOKUP("K-999",A2:A7,D2:D7,"SKU not found")

The result is the text "SKU not found". The message can be text in quotes, a number, a cell reference or even another formula. Use "" for an empty-looking cell, or 0 when later arithmetic needs a number.

This argument only handles the case where nothing matched. A #REF! or #VALUE! from a broken range still shows through, which is what you want: a real fault should stay visible.

How to look up a value to the left

VLOOKUP can only return columns to the right of the one it searches. XLOOKUP has no such rule. Find the SKU of the "Standing desk", which sits in column A, left of the product name in column B:

=XLOOKUP("Standing desk",B2:B7,A2:A7)

The result is K-103.

How to return several columns at once

Make the return range wider and the answer spills across the sheet. This pulls the whole record for the SKU in G2:

=XLOOKUP(G2,A2:A7,B2:E7)

In Microsoft 365 and Excel 2021 or later, one formula in a cell fills four cells to the right: Standing desk, Furniture, 4200 and 3. Keep those cells empty or Excel shows #SPILL!. You can feed the lookup an array too, so =XLOOKUP(G2:G3,A2:A7,D2:D7) returns two prices in one go: 4200 for K-103 and 249 for K-100. The dynamic arrays guide explains how spill ranges behave.

How to find the last match instead of the first

"Desk lamp" appears in rows 2 and 7. By default XLOOKUP stops at the first one:

=XLOOKUP("Desk lamp",B2:B7,D2:D7)

That returns 249, the older K-100 price. To get the newest listing, search from the bottom with a search mode of -1. Skip the fourth and fifth arguments with empty commas, or write the match mode as 0:

=XLOOKUP("Desk lamp",B2:B7,D2:D7,,0,-1)

This returns 279, the price for K-105. VLOOKUP cannot do this without extra helper columns.

How to match part of a text with wildcards

Set the match mode to 2 and * stands for any run of characters while ? stands for exactly one. This finds the first product starting with "USB":

=XLOOKUP("USB*",B2:B7,D2:D7,"none",2)

It returns 380. To match on the ending, put the star first:

=XLOOKUP("*arm",B2:B7,A2:A7,"none",2)

That returns K-102. Without match mode 2 the star is just a character, so =XLOOKUP("*lamp",B2:B7,A2:A7) returns #N/A. To search for a real star or question mark, put a tilde in front of it, as in "~*". Our wildcard characters guide has more patterns.

How to find an approximate match for tiers

Bulk discounts work in bands: an order of 64 units gets the discount of the highest tier it reaches. Put these tiers in A1:B5 and the order quantity in D2.

RowABCD
1Min qtyDiscountQuantity
210%64
3105%
45010%
510015%
The formula uses match mode -1, which means exact match, or else the next smaller item:

=XLOOKUP(D2,A2:A5,B2:B5,,-1)

64 is not in the list, the next smaller tier is 50, so the result is 0.1, shown as 10% when the cells are formatted as percentages. Two commas appear before the -1 because the match mode is the fifth argument and we skipped the fourth.

Match mode 1 does the reverse and picks the next larger item. =XLOOKUP(D2,A2:A5,B2:B5,,1) returns 0.15, the 100-unit tier. Use that for jobs like "which delivery band is the first one that can carry this weight". Unlike a VLOOKUP approximate match, the tiers do not have to be sorted when you use the default linear search.

How to do a two-way lookup

A two-way lookup finds a value at the crossing of a row and a column. Here is monthly unit sales by branch in A1:D4, with the branch in F2 and the month in G2.

RowABCDEFG
1BranchJanFebMarBranchMonth
2Cape Town120135150DurbanFeb
3Durban98110104
4Gauteng210205230
Nest one XLOOKUP inside another:

=XLOOKUP(F2,A2:A4,XLOOKUP(G2,B1:D1,B2:D4))

The inner XLOOKUP finds "Feb" in the header row and hands back the whole Feb column, 135, 110 and 205. The outer one finds "Durban" in A2:A4 and picks the second entry from that column. The result is 110. Change F2 or G2 and the answer follows.

How to look up across a row

XLOOKUP works sideways with no separate function. When the labels run across a row, point both arrays at rows. On the branch table above, Durban's figures sit in row 3 under the month headings in row 1:

=XLOOKUP("Feb",B1:D1,B3:D3)

That returns 110, the February figure for Durban. Whole references work too. =XLOOKUP("Durban",A:A,C:C) searches all of column A and also returns 110, and =XLOOKUP("Feb",1:1,3:3) does the same with entire rows. Our HLOOKUP guide covers the older function built for this sideways case.

How to use XLOOKUP with multiple criteria

Matching on two things at once, such as region and month, needs the lookup array built from two columns joined together. That has its own page: XLOOKUP with multiple criteria shows three formulas that work. Start there, then come back for the argument rules.

Match mode and search mode: which to pick

Two small arguments change what the function does more than anything else, so it is worth keeping them in one place.

match_modeBehaviorTypical use
0Exact match only. This is the default.IDs, names, codes
-1Exact match, else the next smaller itemTax bands, discount tiers, grade cut-offs
1Exact match, else the next larger itemDelivery bands, size ceilings
2Wildcard match with *, ? and ~Partial names, codes with a pattern
search_modeBehaviorTypical use
1Search first to last. Default.Most lookups
-1Search last to firstLatest price, latest status
2Binary search, data sorted ascendingVery large sorted lists
-2Binary search, data sorted descendingVery large lists sorted newest first
The binary modes are faster on huge lists but give wrong answers without an error if the data is not actually sorted. Stay on 1 or -1 unless you have measured a slow sheet and know the sort order is guaranteed.

You can combine the two. The arguments ,,-1,-1 give approximate matching while searching from the bottom of the list. Decide the match first, then the direction.

XLOOKUP vs VLOOKUP, HLOOKUP and INDEX MATCH

All four find a value by looking for a key. They differ in how much you have to remember.

TaskXLOOKUPVLOOKUPINDEX MATCH
Default matchExactApproximate, unless you type FALSEExact if you type 0
Return from the leftYesNoYes
Counts columnsNoYes, a column numberNo
Survives an inserted columnYesBreaks if the number is not updatedYes
Custom not-found textBuilt inNeeds IFERRORNeeds IFERROR
Search from the bottomYesNoNeeds a trick
Works in Excel 2019NoYesYes
Rows and columnsOne functionVLOOKUP and HLOOKUPOne pair, but two functions
Choose XLOOKUP when everyone who opens the file has a modern version. Choose INDEX MATCH when the file has to open in Excel 2019 or earlier. Keep VLOOKUP for old workbooks you maintain rather than rewrite. For the horizontal case, the HLOOKUP guide shows the old route and why XLOOKUP is shorter. The lookup basics guide covers LOOKUP, INDIRECT and OFFSET if you meet them in inherited files.

How to move a VLOOKUP formula to XLOOKUP

Converting is mechanical. Take the table array and split it into two ranges: the first column becomes the lookup array, and the column your index number pointed at becomes the return array.

The VLOOKUP version on our sample sheet:

=VLOOKUP(G2,A2:E7,4,FALSE)

It returns 4200. Column 4 of A2:E7 is D, so the XLOOKUP version is:

=XLOOKUP(G2,A2:A7,D2:D7)

Same result, no column count, no FALSE. Three things to carry over:

  1. Delete the trailing FALSE or 0. Exact match is already the default.
  2. If the VLOOKUP ended in TRUE or was left empty for an approximate match, add ,,-1 to the XLOOKUP, and make sure you really wanted that.
  3. If the old formula wrapped the whole thing in IFERROR, move the message into the fourth argument and let genuine errors show.
Do the conversion one formula at a time and compare the old and new answers in two adjacent columns before you delete anything.

Which Excel versions have XLOOKUP

XLOOKUP is available in Microsoft 365 for Windows and Mac, Excel 2021 and Excel 2024 for Windows and Mac, and Excel for the web.

It is not in Excel 2019, Excel 2016 or earlier. If you open a workbook containing XLOOKUP in one of those versions, the formula text carries a _xlfn. prefix and the cell shows #NAME? once the workbook recalculates. The fix is to give the file to someone with a current version, or rewrite the formula with INDEX and MATCH.

A shared file is only as portable as the oldest version that opens it. If you send workbooks to clients or auditors, ask which version they use before you build on XLOOKUP.

XLOOKUP errors and how to fix them

Every error here can be reproduced on the sample sheet.

ErrorCauseFix
#N/AThe value is not in lookup_array. A typo, a stray space or a type mismatch is usually why.Check the spelling. Wrap the lookup value in TRIM. Set the fourth argument if "not found" is a normal outcome.
#N/A on a numberThe lookup value is text that looks like a number, or the other way round.Convert with --D2 or VALUE(D2) so both sides are numbers.
#VALUE!lookup_array and return_array are different sizes, for example =XLOOKUP(G2,A2:A7,D2:D6).Make both ranges the same number of rows.
#NAME?The Excel version has no XLOOKUP, or the function name is misspelled.Check the spelling, then the version table above.
#SPILL!A multi-column result has no room because cells to the right or below are not empty.Clear the blocking cells.
#REF!A referenced column was deleted.Rebuild the range.
A wrong value, no errorThe return range is one row or column off, or the lookup hit a duplicate first.Compare the header over each range and decide whether you want the first or last match.
The text-versus-number case deserves a demonstration. Suppose A2:A4 holds invoice numbers 1001, 1002 and 1003 as real numbers, B2:B4 holds the amounts 500, 750 and 320, and D2 holds the text "1002".
RowABCD
1InvoiceAmountTyped invoice
210015001002
31002750
41003320
Here =XLOOKUP(D2,A2:A4,B2:B4) returns #N/A, because XLOOKUP treats text "1002" and the number 1002 as different values. The fix =XLOOKUP(--D2,A2:A4,B2:B4) returns 750. The double minus forces the text into a number. =XLOOKUP(VALUE(D2),A2:A4,B2:B4) does the same thing in plain words.

Trailing spaces cause the same symptom. If G2 held "K-103 " with a space at the end, =XLOOKUP(G2,A2:A7,D2:D7) returns #N/A on the product sheet, while =XLOOKUP(TRIM(G2),A2:A7,D2:D7) returns 4200.

Habits that keep XLOOKUP honest

These are the checks worth building into every file.

Lock the ranges before you fill down. In a column of prices, write =XLOOKUP(G2,$A$2:$A$7,$D$2:$D$7) so the ranges stay put when you copy the formula. Our absolute reference guide explains the dollar signs.

Remember that a blank returns zero. If the match is found but the return cell is empty, XLOOKUP shows 0, not a blank. Stock for K-102 really is 0 here, so you cannot tell the two apart in the result. When the difference matters, test the return range with ISBLANK or join an empty string: =XLOOKUP("Monitor arm",B2:B7,C2:C7)&"".

Pick first or last on purpose. Duplicates are normal in real data. The default returns the first, so a sorted-oldest-first list gives you the oldest. Search from the bottom when you want the latest.

Use whole columns carefully. =XLOOKUP("K-102",A:A,E:E) returns 0 and is easy to read. Whole-column references are fine for a lookup, but avoid them inside heavy array formulas that Excel has to recalculate often.

Turn the list into a table. With a table named Products, the formula =XLOOKUP([@SKU],Products[SKU],Products[Unit price]) grows with the data and reads like a sentence. Our guide to Excel tables shows the Ctrl+T setup.

What learners get wrong

Between 26 September and 3 November 2026, our XLOOKUP Function lesson logged 3,942 first attempts, and 72.3% were right. The XLOOKUP lesson logged 1,828 first attempts with 77.1% right, and XLOOKUP Function 2 logged 2,606 with 70.3% right. A first attempt is the first check of a screen in a page view, not a head count of people. The wrong answers cluster into four patterns.

1. The return range is one row or column off. On the screen asking for the first name of the performer born in New Orleans, only 53.6% of 360 first attempts were right. The most common wrong answer, seen 58 times, was =xlookup("New Orleans",4:4,1:1). The lookup half is correct. The return half points at row 1, which holds the performer names, not the first names. The corrected form is =xlookup("new orleans",4:4,2:2). A similar slip on the birth city screen, =xlookup("Lil Wayne",1:1,3:3), returned row 3 instead of row 4, 16 times. Before you press Enter, read the label on the row or column you are returning.

2. The match mode sits in the wrong slot. On the range-matching screen, 69.6% of 309 first attempts were right. The most common wrong answer, 35 times, was =xlookup(d2,a2:a5,b2:b5,-1). Excel reads the -1 as the fourth argument, if_not_found, so a value that has no exact match returns -1 itself. The correct form leaves the fourth argument empty: =xlookup(d2,a2:a5,b2:b5,,-1). On our own tier table, =XLOOKUP(D2,A2:A5,B2:B5,-1) returns -1 where the right formula returns 0.1. A neighbor of this mistake is leaving off the fourth argument entirely, as in =xlookup(d2,a2:a5,b2:b5) on the screen that asked for a "not found" message, which returns #N/A for a missing item.

3. Rows and columns get mixed up. On a screen that wanted Wisconsin's 2022 sales with whole columns, only 46.3% of 270 first attempts were right. Typical wrong answers were =xlookup("Wisconsin",3:3,d:d), which searches a row and returns a column, and =xlookup("Wisconsin",1:1,3:3), which searches the wrong direction. The sizes of the two arrays have to agree. When you search a column, return a column. When you search a row, return a row. On the next screen, =xlookup("2022",1:1,3:3) with quotes around 2022 failed because the header holds the number 2022, not the text. Quotes turn a number into text, and XLOOKUP does not treat the two as the same.

4. Typos and a missing equals sign. On the horizontal screen, =xlookup("Snoop Dog",1:1,3:3) appeared 25 times against a header spelled "Snoop Dogg". XLOOKUP needs the exact spelling, which is why pointing at a cell is safer than retyping a name. On the basic price screen, 78.6% of 529 first attempts were right, and xlookup(d2,a2:a5,b2:b5) with no leading equals sign appeared 18 times. Without the equals sign Excel stores plain text.

A worked job: price a customer order

You are asked to price the three lines on the order list in G1:H4 and flag anything that cannot be fulfilled. Use the product sheet from the top of this page.

  1. Pull the unit price. In I2 write =XLOOKUP(G2,$A$2:$A$7,$D$2:$D$7,"Check SKU") and fill down to I4. The prices are 4200, 249 and the text "Check SKU", which tells the person entering orders that K-999 is a typo or a missing product.
  2. Check stock. In J2 write =XLOOKUP(G2,$A$2:$A$7,$E$2:$E$7)>=H2. For K-103 the stock is 3 and the order is for 2, so the result is TRUE. A TRUE or FALSE column is easy to filter and to use in conditional formatting.
  3. Total the valid lines. In K2 write =IF(ISNUMBER(I2),H2*I2,0) and fill down. That gives 8400 for the first line, 1245 for the second and 0 for the line that has no price. Sum column K for the order total, 9645.
If the order list is long, put the product list in a table and switch the ranges to structured references. If the supplier adds a second price for the same product, decide whether the default first match or a last-match search is the right one, and write it into the formula so the next person does not have to guess.

Practice XLOOKUP

Reading about XLOOKUP will not give you the muscle memory. The page already carries an exercise from Practice Lesson 63, so type the formula there rather than read on.

When you want more, move through these in order. Practice Lesson 85 covers not-found messages, left lookups and approximate matching. Practice Lesson 73 moves to lookups across rows and across columns in the same table. Each screen checks your formula, so you find your own slips straight away.

FAQ

How do you use XLOOKUP in Excel?

Type =XLOOKUP(, then the value you are looking for, the range to search and the range to return. Close the bracket and press Enter. For example, =XLOOKUP(G2,A2:A7,D2:D7) searches A2:A7 for the SKU in G2 and returns the price from the same position in D2:D7. Add a fourth argument for a custom not-found message.

What is the difference between XLOOKUP and VLOOKUP?

VLOOKUP needs a column number and can only return columns to the right of the search column. It also defaults to an approximate match. XLOOKUP uses two separate ranges, returns from either side, matches exactly by default, handles missing items itself and can search from the bottom. It is shorter and breaks less when columns move.

Why does my XLOOKUP return #N/A?

Almost always the value is not in the lookup range exactly as typed. Check spelling, trailing spaces and whether one side is a number and the other is text. TRIM removes spaces, and --D2 turns text numbers into real ones. If a missing value is expected, set the fourth argument to your own message.

Can XLOOKUP return multiple columns?

Yes. Make the return range several columns wide, for example =XLOOKUP(G2,A2:A7,B2:E7). In Microsoft 365 and Excel 2021 or later the answer spills across the cells to the right. Those cells must be empty, or Excel shows #SPILL!. You can also return a single column from a wide table by pointing the return range at just that column.

Does XLOOKUP work in Excel 2019 or 2016?

No. XLOOKUP is available in Microsoft 365, Excel 2021 and later, and Excel for the web. In older versions the formula shows #NAME?. If you must support them, use INDEX and MATCH, which work in every version. Ask colleagues which version they have before you share a workbook.

How do you do XLOOKUP with multiple criteria?

Join the criteria into a single lookup value and a single lookup array, or multiply Boolean tests that both must be true. The details, with working examples, are on our page about XLOOKUP with multiple criteria. The short version is that XLOOKUP itself checks one lookup array, so you build that array from two columns.

How do you find the last match with XLOOKUP?

Set the sixth argument, search_mode, to -1, and skip the fourth and fifth with commas: =XLOOKUP("Desk lamp",B2:B7,D2:D7,,0,-1). Excel then searches from the bottom of the range upward and returns the last match, which is 279 for the second "Desk lamp" in the sample list.

Sources

Keep going

Guides people read next.