XLOOKUP Explained: How to Use It, with Examples (and Why VLOOKUP Is Outdated)
Learn how to use XLOOKUP in Excel with four real examples: a basic lookup, a lookup to the left, handling values that aren't found, and matching on two conditions.
If you want to learn how to use XLOOKUP, this guide walks you through it with simple, real examples, one step at a time. XLOOKUP is one of the most useful formulas in Excel. It finds a value in one list and brings back the matching value from another list. It does the same job as the older VLOOKUP, but it is easier to write and it avoids VLOOKUP’s most annoying problems.
If you are completely new to formulas, start with our Excel for beginners guide first. It explains cell references and the $ sign, which we use below.
The problem XLOOKUP solves
Let’s start with a very simple, real situation. A company has two office buildings, Office A and Office B. Each office keeps its own list of staff. We want to know: which employees from Office B are also listed in Office A?
Ten names in each office. Some appear in both lists.
With ten names, you could check by eye. But real lists have hundreds or thousands of rows, and checking by eye is slow and full of mistakes. This is exactly the kind of job XLOOKUP was made for: look for something in a list, and tell me what you found.
The same idea solves many everyday problems:
- Find the price of a product from a price list.
- Find an employee’s name from their ID number.
- Check which customers from this month’s list also ordered last month.
The syntax, in plain English
Every formula has a recipe, called its syntax. Here is the recipe for XLOOKUP:
Four parts. The first three are required; the fourth is optional.
- lookup_value: what to find. For example, the name in cell B2.
- lookup_array: where to look. The column Excel should search, for example A2:A11.
- return_array: what to bring back. The column that holds the answer. When Excel finds a match in row 5 of the lookup_array, it brings back row 5 of the return_array.
- if_not_found: what to show if it isn’t there. Optional. If you leave it out and Excel can’t find the value, you get an
#N/Aerror.
There are two more optional parts (match mode and search mode), but you won’t need them for everyday work. One nice detail: XLOOKUP looks for an exact match unless you tell it otherwise. With VLOOKUP, you had to remember to type FALSE at the end to get an exact match.
Example 1: a basic lookup (a café menu)
Let’s start with the simplest possible case. A small café has its menu in columns A and B. We want to type an item in D2 and have its price appear in E2 automatically.
Click cell E2 and start typing =XL. Excel suggests XLOOKUP; press Tab to accept it. Then fill in the three parts:
=XLOOKUP(D2,A2:A6,B2:B6)
- D2 is what to find: “Latte”.
- A2:A6 is where to look: the list of items.
- B2:B6 is what to bring back: the prices.
Press Enter, and you get $4.25.
Excel finds “Latte” in the blue column (row 3), then brings back row 3 of the gold column.
Here is how Excel thinks: it goes down the blue column until it finds “Latte” in the second position, then takes the second value in the gold column. Now type “Muffin” in D2, and E2 changes to $3.75 instantly. That’s the whole idea of XLOOKUP. Everything else is a variation on it.
Example 2: a lookup to the left
This is where XLOOKUP beats VLOOKUP clearly. Look at this staff list. The employee ID is in column C, but the name is in column A, to its left. We have an ID, E121, and we want the name.
=XLOOKUP(E2,C2:C5,A2:A5)
XLOOKUP searches column C and brings back the name from column A. VLOOKUP cannot do this.
VLOOKUP can only search the first column of a table and bring back something to the right of it. To do this with VLOOKUP, you would have to move the ID column to the front of your table first. With XLOOKUP, the lookup column and the answer column are separate, so they can be anywhere.
Example 3: handling values that aren’t found
Now back to our two offices. We want column C to tell us, for every person in Office B, whether they are also in Office A. Let’s build it step by step.
Click C2 and type =XLOOKUP(. Then:
- What to find: click B2, the first name in Office B. (If you wanted to check Office A against Office B instead, you would start with A2. Here we start with B2 because we are checking Office B’s names.)
- Where to look: click A2, then press Ctrl + Shift + Down Arrow. This selects everything from A2 down to the last name, A11, in one go. Now, this next step is important: press F4. Dollar signs appear, and the range becomes
$A$2:$A$11. We do this because we are going to copy the formula down to every row. Without the dollar signs, Excel would shift the range down one row each time we copy it (A3:A12, then A4:A13, and so on), and the results would be wrong. The dollar signs make it an absolute reference, so every row searches the same list. - What to bring back: we just want to know whether the name exists, so we can bring back the name itself. Select A2:A11 again and press F4.
- If not found: type
"N", for “No”.
=XLOOKUP(B2,$A$2:$A$11,$A$2:$A$11,"N")
Press Enter. C2 shows Emily, which means Emily is in Office B and in Office A. Now double-click the fill handle (the small square at the bottom-right of C2) to copy the formula down to C11.
Six names were found in both offices. Four are only in Office B.
Six people work in both offices. Four people, including Smith in row 3, show N, because XLOOKUP couldn’t find them anywhere in column A.
Without the fourth part, those four cells would show #N/A errors. With ten rows, a few errors are fine. But imagine a sheet with 15 columns and 200,000 rows. Error values everywhere make it messy and confusing, and they break any totals that include them. The if_not_found part keeps it clean.
Making the result easier to read: Y or N
Our column now mixes names and N’s. It would be more intuitive if every row simply said Y (in both offices) or N (only in Office B). We can wrap our formula in an IF formula to do this.
IF asks a question and gives one answer for “yes” and another for “no”. Our question is: did XLOOKUP return “N”? If yes, the answer is “N”. If no, it found the name, so the answer is “Y”.
=IF(XLOOKUP(B2,$A$2:$A$11,$A$2:$A$11,"N")="N","N","Y")
Press Enter and copy it down with the fill handle.
Every row is now a clear Y or N.
This small change pays off on large lists. Press Ctrl + Shift + L to turn on filters, click the arrow on column C, untick everything except Y, and click OK. You now see only the six employees who work in both offices. Without the Y/N column, you would have to scroll through every name to find them.
Example 4: matching on two conditions
Sometimes one value isn’t enough to find the right row. Here is a table of sales by city and month. “Truro” appears twice and “Feb” appears three times, so neither one alone tells Excel which row we mean. We need the row where the city is Truro and the month is Feb.
=XLOOKUP(1,(A2:A7=F1)*(B2:B7=F2),C2:C7)
Only row 5 passes both checks, so XLOOKUP returns its sales: $2,650.
This looks scary, so let’s break it into small pieces:
(A2:A7=F1)checks every city against “Truro”. Each row gets TRUE or FALSE.(B2:B7=F2)checks every month against “Feb”. Again, TRUE or FALSE for each row.- The
*multiplies the two checks. In Excel, TRUE counts as 1 and FALSE counts as 0. So a row only gets 1 if both checks are true (1 × 1 = 1). Every other row gets 0. - Then XLOOKUP looks for the value 1 in that list of 1s and 0s, and brings back the sales from the same row.
You don’t need to remember why it works to use it. Just follow the pattern: =XLOOKUP(1, (first column = first value) * (second column = second value), answer column). You can add a third condition with another *( … ).
XLOOKUP vs VLOOKUP
Here is a side-by-side comparison:
| XLOOKUP | VLOOKUP | |
|---|---|---|
| Default match | Exact | Approximate (you must type FALSE for exact) |
| Can look to the left | Yes | No, only to the right |
| Answer column | You select it directly | You count columns and type a number |
| Inserting a column in the table | Keeps working | Can break, because the column number doesn’t change |
| Built-in “not found” message | Yes, the fourth part | No, you need IFERROR around it |
| Works in Excel 2019 and older | No | Yes |
The column-number point deserves a moment. In VLOOKUP you write something like =VLOOKUP(D2,A2:C10,3,FALSE), where 3 means “the third column”. If someone later inserts a new column in the middle of the table, the answer moves to the fourth column, but your formula still says 3, so it quietly returns the wrong data. XLOOKUP points at the actual column, so it adjusts automatically.
VLOOKUP still has one real advantage: it works in every version of Excel. If you share files with people who use Excel 2019 or older, they will see errors where you used XLOOKUP.
Common errors and how to fix them
#N/A: the value wasn’t found. Either it really isn’t in the list (add the fourth part to show a friendly message), or it looks the same but isn’t. The two usual causes are an extra space at the end of a name ("Emily " is not "Emily") and a number stored as text. Wrap the value in TRIM() to remove extra spaces, for example =XLOOKUP(TRIM(D2),A2:A6,B2:B6).
#VALUE!: the ranges are different sizes. The lookup_array and the return_array must have the same number of rows. A2:A6 with B2:B7 gives this error. Check that both ranges start and end on the same rows.
#NAME?: Excel doesn’t recognise the formula. Either there is a typo in the name (XLOKUP), or your version of Excel doesn’t have XLOOKUP. In that case, use VLOOKUP or INDEX and MATCH instead.
Wrong results after copying down. You probably forgot the dollar signs. Click the formula in the second row and check whether the ranges moved. Fix the first one with F4 and copy it down again.
Frequently asked questions
Does XLOOKUP work in older versions of Excel?
XLOOKUP is available in Excel for Microsoft 365, Excel 2021, Excel 2024 and Excel for the web. It is not available in Excel 2019, 2016 or older, where it shows a #NAME? error.
Does XLOOKUP work in Google Sheets?
Yes. Google Sheets supports XLOOKUP, and the examples in this guide are written the same way there.
Can XLOOKUP return more than one column?
Yes. If the return_array covers several columns, for example B2:D6, XLOOKUP returns all of them, spilling the answers into the cells to the right. Make sure those cells are empty first.
Should I stop using VLOOKUP?
For your own work in a modern version of Excel, yes, XLOOKUP is simpler and safer. Keep VLOOKUP in mind for files shared with people on older versions, and learn to read it, because you will find it in many existing spreadsheets.
Next step: once you can find values, learn to summarize them. Our pivot table tutorial shows how to turn a long list into a clear summary in under a minute.
Need help with lookups in your own spreadsheet? Book a 1-on-1 Excel session and we will fix it together.