Software & OS

How to Use XLOOKUP in Excel (Syntax and Examples)

To use XLOOKUP, type =XLOOKUP(lookup_value, lookup_array, return_array): Excel searches lookup_array for the value and returns the item in the same position from return_array. For example, =XLOOKUP(F2, A2:A6, B2:B6) finds the value of F2 in A2:A6 and returns the matching name from B2:B6.

XLOOKUP is Microsoft's replacement for VLOOKUP and HLOOKUP. Microsoft's VLOOKUP page describes it as "an improved version of VLOOKUP that works in any direction and returns exact matches by default." Everything below uses the same small table, so you can recreate it in a blank sheet.

The data used in these examples

Put this in A1:D6 of a new sheet. It is made-up sample data.

A (ID)B (Name)C (Department)D (Salary)
101MaraSales52000
102JoelSupport47000
103PriyaSales61000
104TomasFinance58000
105InesSupport49000

Row 1 holds the headers. In cell F2, type the ID you want to look up, for example 103.

XLOOKUP syntax

=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
ArgumentRequiredWhat it does
lookup_valueYesThe value to search for. If you omit it, XLOOKUP returns blank cells it finds in lookup_array.
lookup_arrayYesThe range or array to search.
return_arrayYesThe range or array to return a value from.
if_not_foundNoText to return when there is no valid match. If omitted, you get #N/A.
match_modeNoHow to match. Default is 0 (exact match).
search_modeNoSearch direction or method. Default is 1 (first to last).

XLOOKUP returns the item for the first match it finds. Only the first three arguments are required for a normal lookup.

How to write your first XLOOKUP

To get the name for the ID in F2:

=XLOOKUP(F2, A2:A6, B2:B6)

With 103 in F2, Excel finds 103 at position 3 in A2:A6 and returns the third item of B2:B6. Example result: Priya.

Because match_mode defaults to 0, the match is exact. You do not need to add FALSE or 0 the way you do with VLOOKUP.

How to return several columns at once

Microsoft notes that XLOOKUP can return multiple columns, so one formula gives you several values. Make return_array wider:

=XLOOKUP(F2, A2:A6, B2:D6)

Example result for ID 103: the name, department and salary of that row (Priya, Sales, 61000) across three adjacent cells.

How to show a message instead of #N/A

If you look up 999, nothing matches and the formula returns #N/A. Put your own text in the fourth argument. Text must be in double quotation marks:

=XLOOKUP(F2, A2:A6, B2:B6, "ID not found")

Now 999 returns ID not found, and 103 still returns Priya.

How to look up to the left

VLOOKUP needs the lookup value in the first column of its table. XLOOKUP takes the two ranges separately, so the return column can be on either side. To find the ID of a person by name, where the ID sits to the left of the name:

=XLOOKUP("Tomas", B2:B6, A2:A6)

Example result: 104. The VLOOKUP equivalent would need the name column moved in front of the ID column first.

How to do an approximate match (brackets and tiers)

Set match_mode to -1 to get an exact match or, failing that, the next smaller item. Set it to 1 for the next larger item. This suits tax bands, commission tiers and discount levels. Suppose the thresholds are in H2:H5 and the rates in I2:I5 (made-up numbers):

H (Income from)I (Rate)
010%
1000012%
4000022%
8500024%
=XLOOKUP(52000, H2:H5, I2:I5, "No band", -1)

There is no 52000 in H2:H5, so with -1 Excel takes the next smaller item, 40000, and returns 22%. Note that the fourth argument is a placeholder here, so the match mode can go in fifth position.

All four match_mode values:

ValueBehavior
0Exact match. Returns #N/A if none is found. This is the default.
-1Exact match. If none is found, returns the next smaller item.
1Exact match. If none is found, returns the next larger item.
2Wildcard match, where *, ? and ~ have special meaning.

How to match with wildcards

With match_mode 2, * stands for any run of characters and ? for a single character. To find the first name that starts with "Pri":

=XLOOKUP("Pri*", B2:B6, A2:A6, "No match", 2)

Example result: 103. Use ~ in front of a literal * or ? when you need to search for the character itself.

How to find the last match instead of the first

By default, search_mode is 1 and XLOOKUP stops at the first match from the top. Set it to -1 to search from the last item backwards. Sales appears twice in C2:C6, for IDs 101 and 103. To get the ID of the last person in Sales:

=XLOOKUP("Sales", C2:C6, A2:A6, "None", 0, -1)

Example result: 103. With the default search direction you would get 101.

The other two values, 2 and -2, run a binary search on data sorted ascending or descending. Microsoft warns that unsorted data gives invalid results with them, so use them only on data you know is sorted.

How to do a two-way lookup

Microsoft's page shows that nesting one XLOOKUP inside another returns a value at a row and column intersection. The inner formula picks a column, and the outer one picks the row. For a table with names down the left and months across the top, where the row label is in D2 and the column label is in C3:

=XLOOKUP(D2, $B6:$B17, XLOOKUP($C3, $C5:$G5, $C6:$G17))

This is the formula from Microsoft's example, with those cell references. Adjust the ranges to your own layout.

XLOOKUP vs VLOOKUP

XLOOKUPVLOOKUP
Default matchExactApproximate if range_lookup is omitted
Return columnSeparate range, either sideCounted by number from the first column of the table
Missing valueif_not_found argumentWrap in another function to replace #N/A
Insert a column in the tableRanges adjust, no column number to breakHard-coded col_index_num can point at the wrong column
Excel 2016 and 2019Not availableAvailable

The VLOOKUP equivalent of the first example is =VLOOKUP(F2, A2:D6, 2, FALSE). Per Microsoft, omitting the last argument gives an approximate match, and a col_index_num larger than the table width returns #REF!.

Where XLOOKUP is available

As of November 2026, Microsoft lists XLOOKUP for Excel for Microsoft 365, Excel 2024 and Excel 2021 on Windows and Mac, and for Excel on iPad, iPhone and Android. Microsoft's page states it is not available in Excel 2016 or 2019. If you share a file with someone on those versions, they can open it, but a person who needs to recalculate those formulas should use VLOOKUP or INDEX with MATCH instead.

If XLOOKUP still returns #N/A

  • Check the values really match. A trailing space in one cell, or an ID stored as text in one range and as a number in the other, means no match. Microsoft's VLOOKUP page lists numbers or dates stored as text as a cause of wrong results.
  • Check you are in exact mode. If you set match_mode to 2, * and ? in your lookup value are treated as wildcards.
  • Check the range sizes. Keep lookup_array and return_array the same height (or width), so each position lines up.
  • Use the fourth argument while debugging. A message like "not found" makes it clear the lookup ran and simply had no match.

Frequently asked questions

Which versions of Excel have XLOOKUP?
According to Microsoft's documentation, XLOOKUP is available in Excel for Microsoft 365, Excel 2024 and Excel 2021 on Windows and Mac, and in Excel for iPad, iPhone and Android. It is not available in Excel 2016 or Excel 2019. A workbook that contains XLOOKUP can still be opened in those older versions.
Why does XLOOKUP return #N/A?
XLOOKUP returns #N/A when it finds no valid match and you did not supply the fourth argument, if_not_found. Check for extra spaces, numbers stored as text, and a lookup_array that does not contain the value. To show your own message instead, pass text as the fourth argument, for example "Not found".
Can XLOOKUP look to the left of the lookup column?
Yes. The return_array can be on either side of the lookup_array, because the two ranges are separate arguments. VLOOKUP can only return a value from a column to the right of the lookup column.
Is XLOOKUP case-sensitive?
Microsoft's XLOOKUP page does not describe case sensitivity, so this article does not claim either way. If case matters for your data, test the formula on a few values that differ only by case before relying on it.

Sources