
XLOOKUP in Excel: Syntax, Examples, and When to Skip VLOOKUP
XLOOKUP searches one range for a value and returns the match from another: =XLOOKUP(lookup_value, lookup_array, return_array). It is exact by default, looks left or right, and handles not-found, approximate and wildcard matches. Syntax, six examples and which Excel versions have it.
Tech Talk News Editorial
8 min read
Key takeaways
- XLOOKUP is =XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode]); only the first three arguments are required, and it returns an exact match by default.
- match_mode takes 0 for exact, -1 for exact or next smaller, 1 for exact or next larger and 2 for wildcard, while search_mode takes 1 for first to last, -1 for last to first, 2 for binary ascending and -2 for binary descending.
- Unlike VLOOKUP, which can only look left to right and defaults to an approximate match, XLOOKUP can return a value from a column to the left of the lookup column and can return several columns from one formula.
- XLOOKUP is available in Excel for Microsoft 365, Excel for the web, Excel 2024 and Excel 2021, and Microsoft says it is not available in Excel 2016 or Excel 2019.
- If no match is found and if_not_found is omitted, XLOOKUP returns #N/A; supplying text such as "Not found" replaces that error without a separate IFERROR wrapper.
On this page7 sections
XLOOKUP is the Excel function that finds a value in one range and returns the matching value from another range. The shortest form is =XLOOKUP(lookup_value, lookup_array, return_array), and it returns an exact match unless you ask for something else.[1]
It is in Excel for Microsoft 365, Excel for the web, Excel 2024 and Excel 2021. It is not in Excel 2016 or Excel 2019. I use it in place of VLOOKUP every time the workbook is mine to choose, for reasons the comparison below spells out.
XLOOKUP syntax: all six arguments
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode]). The first three are required.[1]
- lookup_value: what to search for. If you leave it out, XLOOKUP returns blank cells it finds in lookup_array.
- lookup_array: the range or array to search.
- return_array: the range or array to return values from.
- if_not_found: text to return when there is no valid match. Omit it and you get #N/A.
- match_mode: 0 is an exact match and the default. -1 is an exact match, or the next smaller item if there is none. 1 is an exact match, or the next larger item. 2 is a wildcard match, where *, ? and ~ have special meaning.
- search_mode: 1 searches from the first item to the last and is the default. -1 searches from the last item to the first. 2 is a binary search that needs the lookup range sorted ascending, and -2 is a binary search for descending order. Microsoft warns that unsorted data gives invalid results for the two binary modes.[1]
Basic examples you can copy
Take a list of employees. Column A holds IDs 101 to 105, column B holds names, column C holds departments, in rows 2 to 6. Row 3 is ID 102, Okafor, Finance.
- Exact lookup.
=XLOOKUP(102,A2:A6,B2:B6)returns Okafor. - Several columns at once.
=XLOOKUP(102,A2:A6,B2:C6)returns Okafor and Finance side by side. Microsoft's own example returns an employee name and department from one formula, something VLOOKUP can't do.[1] - A friendly not-found.
=XLOOKUP(999,A2:A6,B2:B6,"Not found")shows Not found in place of #N/A. - Looking left.
=XLOOKUP("Okafor",B2:B6,A2:A6)searches the name column and returns the ID, which sits to its left. The lookup and return columns can be on either side of each other.[1]
That last one is the reason most people switch. VLOOKUP's own Microsoft page says the lookup value must be in the first column of the range, so the answer has to be to the right.[2]
Approximate match, wildcards and last match
Match modes are where XLOOKUP replaces three different tricks.
Tiers and brackets. Say a commission schedule has thresholds 0, 1000, 5000 and 10000 in D2:D5 and rates of 0%, 2%, 4% and 6% in E2:E5. Sales of 6,200 should earn 4%. =XLOOKUP(6200,D2:D5,E2:E5,,-1) finds no exact 6200, takes the next smaller threshold, 5000, and returns 4%.
The empty slot is the skipped if_not_found. Use 1 when you want the next larger item, such as the first shipping tier that fits a weight.[1]
Wildcards. Set match_mode to 2. =XLOOKUP("Ok*",B2:B6,A2:A6,"none",2) returns the ID of the first name starting with Ok. A * stands for any run of characters, a ? for one character, and a ~ lets you search for a literal * or ?.[1]
The last match, not the first. XLOOKUP returns the first match it finds, reading top to bottom. Set search_mode to -1 and it reads from the bottom. If a sheet logs one row per order in date order, =XLOOKUP(A2,Orders!A:A,Orders!C:C,,0,-1) returns the most recent order for a customer.
Two-way lookups. Nest one XLOOKUP inside another to match a row and a column. Microsoft shows nested XLOOKUPs doing a vertical and a horizontal match, the job people used INDEX and MATCH for.[1]
Heads up
XLOOKUP vs VLOOKUP vs INDEX and MATCH
VLOOKUP's syntax is VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup]). Two defaults bite people. If you leave range_lookup out, it defaults to TRUE, an approximate match that assumes the first column is sorted. And you count the return column by number, starting at 1 for the left-most column of the range.[2]
- Default match. XLOOKUP is exact. VLOOKUP is approximate unless you type FALSE or 0. Microsoft's VLOOKUP page itself now points readers to XLOOKUP as an improved version that returns exact matches by default.[2]
- Direction. XLOOKUP looks left or right. VLOOKUP only looks left to right.
- Breaks when columns move. VLOOKUP's column number is a plain integer, so inserting a column inside the table range silently shifts what it returns. XLOOKUP's return_array is a real range, and Excel adjusts it when you insert a column.
- Not found. XLOOKUP has the built-in fourth argument. VLOOKUP needs an IFERROR wrapper.
- HLOOKUP. XLOOKUP replaces it too, because it searches rows as readily as columns.[1]
INDEX and MATCH is the old pair that also looks in any direction. It still has one real advantage: it works in every version of Excel. So my rule is short. Use XLOOKUP if everyone who opens the file has Microsoft 365, 2021 or 2024. Use INDEX and MATCH if the file goes to anyone on Excel 2019 or 2016.
Takeaway
Type XLOOKUP(value, where_to_look, what_to_return) and add the fourth argument when the value might be missing. Reach for the other arguments only when the data is tiered, wild or needs the last match.
Which Excel versions have XLOOKUP
- Excel for Microsoft 365 on Windows, Mac and the web: yes.
- Excel 2024 and Excel 2021: yes.
- Excel 2019 and Excel 2016: no.
Microsoft's own page is slightly confusing here. Its Applies To list names Excel 2016 and 2019, yet its remarks say XLOOKUP isn't available in those versions and that a workbook containing it may still be opened there.[1] Trust the remark. If a colleague opens your file in Excel 2019, plan for the formulas not to calculate.
If XLOOKUP returns #N/A or the wrong thing
- #N/A. Microsoft says this means no valid match was found and if_not_found was omitted.[1] Check the value exists in lookup_array.
- Numbers stored as text. The number 102 and the text "102" don't match. Convert one side so both are numbers.
- Trailing spaces. "Okafor " is not "Okafor." Clean the column with TRIM.
- Approximate answers you didn't expect. A match_mode of -1 or 1 never errors when the exact value is missing. It picks a neighbor. Use 0 when an exact match is the only valid answer.
- Wrong answers with a binary search. You chose search_mode 2 or -2 on unsorted data. Sort it, or go back to 1.
- Duplicate IDs. XLOOKUP returns the first match, so a duplicated key hides the second row. Find repeats with Remove Duplicates or the UNIQUE function.
If the value you look up comes from a person, constrain it. A drop-down list in Excel guarantees the lookup value is spelled the way your table spells it, which cures half of the #N/A errors I see.
Primary sources
- 1.PrimaryXLOOKUP function. Microsoft Support. Syntax, arguments, match and search modes, examples and availability.
- 2.PrimaryVLOOKUP function. Microsoft Support. Syntax, the approximate-match default and the first-column rule.
Frequently asked questions
6 questions
What is XLOOKUP in Excel?
XLOOKUP is a lookup function that searches a range for a value and returns the matching item from another range. Its syntax is =XLOOKUP(lookup_value, lookup_array, return_array). It is exact by default, can look in either direction, and Microsoft positions it as the replacement for VLOOKUP and HLOOKUP.
Is XLOOKUP better than VLOOKUP?
Yes for most work, because it defaults to an exact match, looks left or right, returns several columns and takes a not-found message. VLOOKUP can only look from left to right and defaults to an approximate match that needs sorted data. VLOOKUP still runs in Excel 2016 and 2019, where XLOOKUP does not.
Which Excel versions have XLOOKUP?
Excel for Microsoft 365, Excel for the web, Excel 2024 and Excel 2021 have it. Microsoft states that XLOOKUP is not available in Excel 2016 and Excel 2019. If someone you share a workbook with uses one of those, use INDEX and MATCH instead.
How do I stop XLOOKUP returning #N/A?
Fill in the fourth argument, if_not_found. For example, =XLOOKUP(999,A2:A6,B2:B6,"Not found") returns the text Not found when 999 is not in the list. Without it, XLOOKUP returns #N/A when there is no valid match. If a match should exist, check for text stored as numbers or stray spaces.
Can XLOOKUP do an approximate match or use wildcards?
Yes. Set match_mode to -1 for the next smaller item, 1 for the next larger item, or 2 for a wildcard match, where *, ? and ~ have special meaning. For tiered lookups such as tax or commission brackets, use -1 or 1; the data does not need to be sorted unless you also choose a binary search.
Can XLOOKUP look to the left?
Yes. The lookup range and the return range can be on either side of each other, so you can search a name column and return an ID from a column to its left. VLOOKUP cannot do that, because Microsoft documents that it only looks from left to right.
Keep reading
Written by
Tech Talk News Editorial
Computer engineering background. Writes about software, AI, markets, and real estate, and the places where the three meet.
About Tech Talk News

