Learn › Article
How to Use XLOOKUP Instead of VLOOKUP in Excel
Short answer: replace =VLOOKUP(F2,A2:D6,3,FALSE) with =XLOOKUP(F2,A2:A6,C2:C6). Instead of counting columns, you point XLOOKUP at the column to search and the column to return. It matches exactly by default, and it can look to the left.
XLOOKUP is available in Excel for Microsoft 365, Excel 2021, Excel 2024 and Excel for the web. It is not in Excel 2019 or earlier, so use VLOOKUP there.
The syntax
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
Only the first three arguments are required:
- lookup_value: what you are looking for.
- lookup_array: the single row or column to search.
- return_array: the row or column to take the answer from.
- if_not_found (optional): text to show instead of
#N/A. - match_mode (optional):
0exact (the default),-1exact or next smaller,1exact or next larger,2wildcard. - search_mode (optional):
1first to last (the default),-1last to first.2and-2are binary searches, which need sorted data.
A worked example
Type this table into A1:D6:
| Product ID | Product | Price | Stock |
|---|---|---|---|
| 101 | Pen | 1.20 | 40 |
| 102 | Notebook | 3.50 | 15 |
| 103 | Stapler | 6.00 | 8 |
| 104 | Ruler | 0.90 | 60 |
| 105 | Marker | 2.25 | 22 |
In F2 type 103. Now compare the two approaches:
- In G2, VLOOKUP:
=VLOOKUP(F2,A2:D6,3,FALSE)gives 6. - In G3, XLOOKUP:
=XLOOKUP(F2,A2:A6,C2:C6)gives 6.
Both return the Stapler's price. The XLOOKUP version shows exactly which column is searched (A) and which is returned (C), so you never count to 3.
Why XLOOKUP is easier
| Feature | VLOOKUP | XLOOKUP |
|---|---|---|
| Default match | Approximate (unless you add FALSE) | Exact |
| Look to the left | No | Yes |
| Column reference | Number you count | Real range |
| Not-found message | Needs IFERROR or IFNA | Built-in argument |
| Search from the bottom | No | Yes |
Common tasks
Look up to the left
VLOOKUP can only return columns to the right of the one it searches. XLOOKUP has no such limit. To find the ID of the Ruler:
=XLOOKUP("Ruler",B2:B6,A2:A6) gives 104.
Show a friendly message when nothing matches
=XLOOKUP(999,A2:A6,C2:C6,"Not found") gives Not found.
With VLOOKUP you would wrap the whole formula in IFERROR, which also hides unrelated errors. The fourth argument only handles the not-found case.
Return several columns at once
Make the return range wider:
=XLOOKUP(F2,A2:A6,B2:D6)
Type it in one cell with empty space to its right, such as G5, and the result spills across G5:I5: Stapler, 6, 8. This needs a version with dynamic arrays (Microsoft 365, Excel 2021 or later). If any of those cells are occupied, you will see a #SPILL! error.
Approximate match for bands, such as grades
In K1:L6 type this grade table:
| Min score | Grade |
|---|---|
| 0 | F |
| 50 | D |
| 60 | C |
| 70 | B |
| 80 | A |
Then use match mode -1 (exact match, or the next smaller value):
=XLOOKUP(72,K2:K6,L2:L6,,-1) gives B, because 70 is the largest minimum that does not exceed 72.
The empty space between the two commas skips the not-found argument. Unlike VLOOKUP's approximate match, this works with the default search mode even if the table is not sorted, though a sorted band table is still easier to read.
Match part of a text
Use match mode 2 for wildcards:
=XLOOKUP("Note*",B2:B6,C2:C6,"",2) gives 3.5 (the price of the Notebook).
Find the last match instead of the first
If a value appears more than once, set the search mode to -1 to search from the bottom:
=XLOOKUP(F2,A2:A6,C2:C6,"",0,-1)
In our table every ID appears once, so this returns 6 just like the normal version. It only changes the result when there are duplicates.
Converting an old VLOOKUP step by step
- Note the lookup value (the first argument of VLOOKUP).
- Take the table range and split it: the first column becomes the lookup array (A2:A6).
- Use the column that the column number pointed to as the return array. In
A2:D6with column3, that is C2:C6. - Delete
FALSE. Exact match is already the default. - If you used
IFERRORonly to hide#N/A, move your message into the fourth argument.
Common errors
- #N/A: no match was found. Check for extra spaces, or numbers stored as text in one column but not the other.
- #VALUE!: the lookup and return ranges are different sizes. For a column lookup, both must have the same number of rows (A2:A6 and C2:C6 both have five).
- #SPILL!: something is in the way of a multi-cell result. Clear the cells to the right.
- #NAME?: your Excel version does not have XLOOKUP, or the name is misspelled.
When to keep using VLOOKUP
VLOOKUP is still fine for simple tasks and for files shared with older Excel versions. If an assignment specifically asks for VLOOKUP, use it. Otherwise, XLOOKUP is usually clearer and safer.
Stuck on the whole assignment?
If you are stuck on a whole assignment, upload your assignment to Excelerant and get the finished Excel file with each step explained.
Frequently asked questions
Does XLOOKUP replace VLOOKUP completely?
For most tasks, yes, if your Excel version has it. VLOOKUP still works and remains useful for compatibility with older versions.
Do I need to sort my data for XLOOKUP?
No. With the default exact match, order does not matter. Sorting only matters if you choose a binary search mode (2 or -2), which most students will not need.
Is XLOOKUP case-sensitive?
No. Like VLOOKUP, it treats "pen" and "Pen" as the same text.