XLOOKUP vs VLOOKUP: which should you use?
XLOOKUP does everything VLOOKUP does with fewer ways to go wrong. Here's the same lookup written both ways, the five differences that matter, and when VLOOKUP is still the right call.
#N/A means not available: a lookup function (VLOOKUP, XLOOKUP, MATCH, HLOOKUP) searched for a value and didn’t find it. Sometimes that’s true, and the value really is missing. More often the value is there but differs in a way you can’t see, such as a trailing space or a number stored as text. Find which case you have, fix the data, and only then decide whether to hide the error with IFNA.
A-199 isn’t in the list, so the lookup has nothing to return. This is the one case where #N/A is the right answer, and the fix is to decide what to show instead.
| Row | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| 1 | Code | Product | Price | Find | Price | |
| 2 | A-101 | Keyboard | $49.00 | A-199 | #N/A | |
| 3 | A-102 | Mouse | $19.00 | |||
| 4 | A-103 | Monitor | $189.00 | |||
| 5 | A-104 | Webcam | $59.00 | |||
| 6 | A-105 | Headset | $79.00 |
With XLOOKUP, put the fallback in its fourth argument. With VLOOKUP or MATCH, wrap the formula in IFNA:
=XLOOKUP(E2,A2:A6,C2:C6,"Not listed") → Not listed=IFNA(VLOOKUP(E2,A2:C6,3,FALSE),"Not listed") → Not listedE2 holds A-103 with a space at the end, often left behind by a copy from another system. To Excel, A-103 and A-103 are different text.
| Row | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| 1 | Code | Product | Price | Find | Price | |
| 2 | A-101 | Keyboard | $49.00 | A-103 | #N/A | |
| 3 | A-102 | Mouse | $19.00 | |||
| 4 | A-103 | Monitor | $189.00 | |||
| 5 | A-104 | Webcam | $59.00 | |||
| 6 | A-105 | Headset | $79.00 |
Check with =LEN(E2): 6 characters for a 5-character code gives it away. Clean the value inside the formula with TRIM, or clean the column once with Find and Replace.
=XLOOKUP(TRIM(E2),A2:A6,C2:C6) → $189.00The IDs in column A are numbers; the 1052 in D2 is text (left-aligned, often with a small green triangle). 1052 the number and “1052” the text never match.
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | ID | Name | Find | Name | |
| 2 | 1041 | Ana Kola | 1052 | #N/A | |
| 3 | 1052 | Ben Ortiz | |||
| 4 | 1063 | Chloe Park |
Turn the text into a number inside the formula with --D2 (or VALUE), or fix the cell with Data › Text to Columns › Finish.
=XLOOKUP(--D2,A2:A4,B2:B4) → Ben OrtizLeave out VLOOKUP’s fourth argument and it does an approximate match, which assumes the first column is sorted. On unsorted data it can return #N/A for a value that’s there, or worse, the wrong row. Always end it with FALSE: =VLOOKUP(E2,A2:C6,3,FALSE).
A lookup over A2:A5 can’t find a code on row 6. This happens when rows are added below a fixed range. Turn the data into a table (Ctrl+T) so ranges grow with it, or extend the range.
VLOOKUP only searches the first column of its table. If the codes are in column B and the table starts at A, every lookup misses. Start the table at the column you search, or use XLOOKUP, which takes the search column as its own argument.
Your task: In F2, return the price of the code in E2, or the text "Not listed" when the code isn't there.
Graded live| Row | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| 1 | Code | Product | Price | Find | Price | |
| 2 | B-201 | Desk | $240.00 | B-207 | ||
| 3 | B-202 | Chair | $135.00 | |||
| 4 | B-203 | Lamp | $42.00 | |||
| 5 | B-204 | Shelf | $88.00 |
Write the formula in the bar above, then press Check or Enter.
Look up E2 in A2:A5 and return from C2:C5. Then add "Not listed" as XLOOKUP's fourth argument, or wrap the lookup in IFNA.
=XLOOKUP(E2,A2:A5,C2:C5,"Not listed") Any formula that returns the same result passes.
Both can hide #N/A, but IFERROR hides every error. If a typo turns XLOOKUP into XLOKUP, IFERROR quietly shows “Not listed” and you never learn the formula is broken. IFNA only replaces #N/A, so real mistakes still show. Use IFNA for lookups.
Not available. A lookup function such as VLOOKUP, XLOOKUP or MATCH searched for a value and didn't find it.
Wrap the lookup in IFNA: =IFNA(VLOOKUP(E2,A2:C6,3,FALSE),0). With XLOOKUP, use its fourth argument instead: =XLOOKUP(E2,A2:A6,C2:C6,0).
The two values only look the same. Usually one has a trailing space or is a number stored as text. Compare them with =A4=E2: FALSE confirms they differ.
IFNA for lookups. IFERROR also hides #REF!, #NAME? and other errors that mean your formula is broken.
Guides that build on this one.
XLOOKUP does everything VLOOKUP does with fewer ways to go wrong. Here's the same lookup written both ways, the five differences that matter, and when VLOOKUP is still the right call.
#REF! means a formula points at a cell that isn't there: deleted, or past the edge of a range. The usual causes and fixes, with a practice sheet.
#VALUE! means a formula got the wrong kind of value, most often text where it needs a number. The usual causes and fixes, with a practice sheet.
Practise in a live grid that grades what your formula calculates, with a specific hint when it's wrong.
Runs in your browser · Graded on your result · No install