XLOOKUP vs INDEX MATCH vs VLOOKUP: which to use in an Excel test
All three find a value in a table. In a test, the choice matters for two reasons: which Excel you are given, and which one breaks when the sheet changes.
In short: Use XLOOKUP if the test's Excel has it (Microsoft 365, Excel 2021 or later, Excel for the web). If not, use INDEX MATCH. Use VLOOKUP only with FALSE as the last argument, because by default it finds a near match and returns a wrong price with no error.
The test question
Brief: "Bring the price into the order sheet." The code you need is in G2: P-104.
| A: Code | B: Product | C: Price | |
|---|---|---|---|
| 2 | P-101 | Desk | 250 |
| 3 | P-102 | Chair | 90 |
| 4 | P-103 | Lamp | 40 |
| 5 | P-104 | Shelf | 145 |
| 6 | P-105 | Cabinet | 210 |
Three answers that all return 145
| Function | Formula |
|---|---|
| XLOOKUP | =XLOOKUP(G2,A2:A6,C2:C6,"Not found") |
| INDEX MATCH | =INDEX(C2:C6,MATCH(G2,A2:A6,0)) |
| VLOOKUP | =VLOOKUP(G2,A2:C6,3,FALSE) |
Trap 1: VLOOKUP's default is a near match
Leave off FALSE and look up P-106, a code that isn't in the list. =VLOOKUP("P-106",A2:C6,3) returns 210, the Cabinet price. There's no error. The codes are sorted, so VLOOKUP takes the last one that comes before P-106.
XLOOKUP's default is an exact match. MATCH with 0 is exact too.
Trap 2: a new column breaks VLOOKUP
Your manager inserts a Category column between Product and Price. VLOOKUP still says "column 3", which is now Category, so it returns Storage instead of 145. XLOOKUP and INDEX MATCH point at the Price column itself, so they keep working.
That is why reviewers in finance prefer them. A test that changes the data after you finish will catch this.
Trap 3: the version you get
XLOOKUP isn't in Excel 2019 or earlier. Some test platforms and company laptops still run them. If you type XLOOKUP there, you get #NAME?. Learn INDEX MATCH as well, so you aren't stuck.
Which one to use
| Situation | Use |
|---|---|
| Microsoft 365 or Excel 2021+ | XLOOKUP |
| Older Excel, or unsure | INDEX MATCH |
| Value to the left of the key | XLOOKUP or INDEX MATCH. VLOOKUP can't |
| Price bands or tax brackets | XLOOKUP with match mode -1, or a sorted VLOOKUP with TRUE |
A lookup that returns #N/A for a code you can see is usually a stray space or a number stored as text. The interview questions page covers that fix.
Questions people ask
Is XLOOKUP better than INDEX MATCH?
It's shorter and exact by default, and it has a built-in "not found" value. INDEX MATCH does the same job and works in every Excel version. In a test, use whichever the Excel in front of you supports.
Why does VLOOKUP return the wrong value without an error?
Without FALSE as the last argument, VLOOKUP does an approximate match. If the exact key is missing, it returns the nearest smaller one. Always end VLOOKUP with FALSE unless you want bands.
Can XLOOKUP return several columns?
Yes. In Microsoft 365, give it a return range several columns wide, like B2:C6, and the results spill across.
Now try one that marks itself
The free check gives you an email, a messy export and 10 minutes. It re-runs your formulas on data you haven't seen and shows what broke.