XLOOKUP in Excel: A Step-by-Step Guide
In this article
XLOOKUP is Excel's modern replacement for VLOOKUP and HLOOKUP. It searches a range or array for a value and returns the corresponding item from a second range or array — and unlike VLOOKUP, it can look to the left, defaults to an exact match, and returns a clean #N/A error instead of a wrong answer when nothing is found. To use it, you need Excel for Microsoft 365, Excel 2021 or later, or Excel for the web; older perpetual versions such as Excel 2019 do not have it. The basic syntax is =XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode]).
What You'll Need
- A version of Excel that supports XLOOKUP: Microsoft 365 (desktop or web), Excel 2021, or Excel for Mac 2021 and later. If you type
=XLOOKUPand Excel does not suggest it, your version does not have it. - A table of data with at least one column (or row) to search and another to return values from.
- Basic familiarity with cell references and ranges, such as
A2:A100.
Step-by-Step
- Set up your data. Put the values you want to search in one column and the values you want returned in another. For example, put product codes in
A2:A50and product names inB2:B50. Keep the two ranges the same height (or width, for a horizontal lookup). - Click the cell where the result should appear. This is where the formula goes — for example,
D2next to the code you are looking up. - Type
=XLOOKUP(. Excel will show the argument names as a tooltip. You can type the arguments separated by commas, or select each range with the mouse. - Enter the lookup value. This is what you are searching for. It can be a cell reference such as
D2, or a literal value in quotes such as"A-100". For example:=XLOOKUP(D2,. - Enter the lookup array. This is the range that contains the values to search — for example
A2:A50. So far:=XLOOKUP(D2, A2:A50,. - Enter the return array. This is the range containing the answer you want — for example
B2:B50. It must be the same size as the lookup array. So far:=XLOOKUP(D2, A2:A50, B2:B50. - Add the optional
if_not_foundargument. This replaces the ugly #N/A error with something readable, such as"Not found"or""for a blank. Example:=XLOOKUP(D2, A2:A50, B2:B50, "Not found"). - Leave match_mode and search_mode alone for a normal exact-match lookup. The defaults are exact match (0) and search first-to-last (1), which is what most people want. Only change them if you need a wildcard, approximate or reverse search (see Tips).
- Close the bracket and press Enter. The formula returns the matching value from the return array. Copy it down the column to look up many values at once.
- Check a few results by eye. Pick two or three rows where you know the correct answer and confirm the formula returns it. This catches mismatched range sizes and stray spaces early.
Common Mistakes
- Mismatched range sizes. The lookup array and return array must contain the same number of rows (or columns, for a horizontal lookup). If they do not, XLOOKUP returns
#VALUE!. - Assuming VLOOKUP behaviour. XLOOKUP defaults to an exact match. If you copy a VLOOKUP formula across, the optional arguments mean different things — check them rather than assuming.
- Forgetting the
if_not_foundargument. Without it, a missing value shows as#N/A, which looks like an error to anyone reading the sheet. - Trailing spaces or text/number mismatches. A code stored as text
"1001"will not match a number1001. UseTRIMor convert the column consistently. - Using it in an old Excel version. Excel 2019 and earlier do not support XLOOKUP and will show
#NAME?. Use INDEX and MATCH there instead.
Tips
- Use a wildcard match by setting
match_modeto 2. Then"A*"finds the first value starting with A. - Set
search_modeto -1 to search from the bottom up, which is handy for finding the most recent entry in a log. - Return a whole row or column by pointing the return array at multiple columns, such as
B2:D50; the formula spills the matching row across adjacent cells. - Wrap the lookup value in
TRIM()if your source data has inconsistent spacing. - Name your ranges (Formulas > Define Name) to make formulas easier to read and audit.
Troubleshooting
- #NAME? error: your Excel version does not support XLOOKUP. Check the version under File > Account (or Excel menu > About Excel on Mac). If it is Excel 2019 or earlier, switch to
=INDEX(return_range, MATCH(lookup_value, lookup_array, 0)). - #VALUE! error: the lookup and return arrays are different sizes. Re-select both ranges and make sure they line up row for row.
- #N/A when the value clearly exists: check for trailing spaces, numbers stored as text, or hidden characters. Try
=XLOOKUP(TRIM(D2), A2:A50, B2:B50, "Not found"). - Wrong match returned: confirm
match_modeis 0 for exact match. A value of -1 or 1 enables approximate matching and can return a nearby but incorrect row. - Formula works in one cell but not when copied: check whether you used absolute references (
$A$2:$A$50) for the lookup and return arrays so they do not shift as you drag the formula down.
Frequently Asked Questions
Does XLOOKUP work in Excel 2019?
No. XLOOKUP is available in Microsoft 365, Excel 2021 and later, and Excel for the web. In Excel 2019 and earlier, use INDEX and MATCH instead.
Can XLOOKUP look to the left?
Yes. Unlike VLOOKUP, XLOOKUP can return values from a column to the left of the lookup column, because you specify the return array separately.
What is the difference between XLOOKUP and VLOOKUP?
XLOOKUP defaults to an exact match, can search in any direction, returns a clean not-found value, and does not break when columns are inserted. VLOOKUP defaults to an approximate match and only looks to the right.
Can XLOOKUP return multiple columns at once?
Yes. Point the return array at several columns, such as B2:D50, and the formula spills the matching row across adjacent cells.
Why do I get #N/A with XLOOKUP?
The lookup value was not found in the lookup array. Check for trailing spaces, text-versus-number mismatches, or a range that does not include the row you expect.
Is XLOOKUP case-sensitive?
No, by default it is not case-sensitive. For a case-sensitive lookup you would need a different approach, such as combining EXACT with other functions.