XLOOKUP in Excel: How to Use It and Examples
In this article
To use XLOOKUP in Excel, enter the formula =XLOOKUP(lookup_value, lookup_array, return_array). This function allows you to find a specific value in one column or row and return a corresponding value from another column or row, regardless of whether the return data is to the left or right of the search column. It replaces older functions like VLOOKUP and HLOOKUP by offering more flexibility and a simpler syntax.
What You'll Need
- A version of Excel that supports XLOOKUP (Microsoft 365, Excel 2021, or Excel for the Web).
- A dataset containing a unique identifier (like an ID number or email) to search for.
- A target range containing the information you want to retrieve.
Step-by-Step
- Identify Your Lookup Value: Decide which piece of information you already have that will act as the "key." For example, if you have a list of employee IDs and you want to find the name associated with ID #105, "105" is your lookup value. You can either type this value directly into the formula in quotation marks (e.g., "105") or click on a cell that contains the value.
- Select the Lookup Array: This is the range of cells where Excel should search for the lookup value. If your employee IDs are listed in column A from row 2 to row 100, your lookup array is
A2:A100. Ensure this range contains only the column or row where the unique identifiers are located. - Select the Return Array: This is the range of cells that contains the data you actually want to retrieve. If the employee names are in column B from row 2 to row 100, your return array is
B2:B100. The return array must be the same size (same number of rows or columns) as the lookup array, or the formula will return a #VALUE! error. - Enter the Basic Formula: In the cell where you want the result to appear, type
=XLOOKUP(. Then, click the cell with your lookup value, type a comma, highlight the lookup array, type another comma, and highlight the return array. Close the parenthesis and press Enter. Example:=XLOOKUP(D2, A2:A100, B2:B100). - Add an "If Not Found" Argument (Optional): XLOOKUP allows you to specify what happens if the value isn't found, preventing the ugly #N/A error. After the return array, add another comma and type your custom message in quotes. Example:
=XLOOKUP(D2, A2:A100, B2:B100, "Employee Not Found"). - Define the Match Mode (Optional): By default, XLOOKUP performs an exact match. If you need something else, add another comma after the "if not found" section. Use
0for exact match (default),-1for exact match or next smaller item,1for exact match or next larger item, and2for wildcard matches. - Define the Search Mode (Optional): The final argument determines the direction of the search. Use
1to search from the first item to the last (default), or-1to search from the last item to the first (reverse search).
Common Mistakes
One of the most frequent errors is mismatched array sizes. If your lookup array spans 50 rows (A2:A51) but your return array spans 49 rows (B2:B50), Excel cannot map the relationship between the two, resulting in a #VALUE! error. Always double-check that the start and end row numbers are identical for both ranges.
Another common mistake is confusing the order of the arguments. Users coming from VLOOKUP often try to select a large table range as the second argument. XLOOKUP does not use a table index number; it requires two separate, specific ranges: one for the search and one for the result. If you select the entire table for the second argument, the formula will fail because it is looking for a single column of identifiers, not a multi-column grid.
Data type mismatches are also a significant hurdle. If your lookup value is stored as text (e.g., "105" with a leading apostrophe) but the lookup array contains numbers (105), XLOOKUP will not see them as a match and will return #N/A. Ensure that both the search key and the search column are formatted as the same data type—either both as numbers or both as text.
Tips
To make your XLOOKUP formulas more durable, use Absolute References (dollar signs). If you plan to drag your formula down a column to look up multiple values, highlight your arrays in the formula and press F4. This changes A2:A100 to $A$2:$A$100. Without this, as you drag the formula down, the search ranges will shift downward, causing the formula to miss data at the top of your list.
Leverage XLOOKUP for "Left Lookups." Unlike VLOOKUP, which requires the lookup column to be the leftmost column in the table, XLOOKUP doesn't care where the columns are. You can search for a value in column G and return a value from column A without rearranging your data. This eliminates the need to move columns or use complex INDEX/MATCH combinations.
Use Named Ranges to make your formulas readable. Instead of =XLOOKUP(D2, A2:A100, B2:B100), you can name the range A2:A100 as "EmployeeIDs" and B2:B100 as "EmployeeNames." Your formula then becomes =XLOOKUP(D2, EmployeeIDs, EmployeeNames), which is much easier to audit and maintain in large workbooks.
Troubleshooting
If your formula returns #N/A, the first step is to verify that the lookup value actually exists in the lookup array. Use the Ctrl+F function to search for the value manually. If it exists but XLOOKUP can't find it, check for hidden spaces. A cell that looks like "105" might actually be "105 " (with a trailing space). You can use the =TRIM() function on your data to remove these invisible characters.
If you see a #VALUE! error, check the dimensions of your arrays. Ensure that if the lookup array is a vertical column, the return array is also a vertical column of the exact same height. If one is a row and the other is a column, the formula will fail.
If the formula returns the wrong value, check your Match Mode. If you accidentally entered 1 or -1 in the fourth argument, Excel is no longer looking for an exact match; it is looking for the nearest value. Delete the match mode argument or set it to 0 to force an exact match.
If the formula simply doesn't exist in your Excel ribbon or returns #NAME?, you are likely using a version of Excel that does not support XLOOKUP. In this case, you must use the older INDEX and MATCH functions together to achieve the same result. To do this, use =INDEX(return_range, MATCH(lookup_value, lookup_range, 0)).
Frequently Asked Questions
Can XLOOKUP return multiple columns at once?
Yes. If you select a return array that spans multiple columns (e.g., B2:D100), XLOOKUP will "spill" the results into the adjacent cells, returning all corresponding values for that row automatically.
Is XLOOKUP faster than VLOOKUP?
In most standard spreadsheets, the speed difference is negligible. However, XLOOKUP is more efficient because it only processes the two specific columns needed rather than loading an entire table array into memory.
Does XLOOKUP work with other workbooks?
Yes, you can reference a lookup array or return array located in a separate Excel file. When the other file is closed, Excel will include the full file path in the formula.
Can I use wildcards with XLOOKUP?
Yes, but you must set the Match Mode argument to 2. This allows you to use an asterisk (*) to represent any number of characters or a question mark (?) to represent a single character in your lookup value.
Can XLOOKUP perform a horizontal search?
Yes. While VLOOKUP is for vertical columns and HLOOKUP is for horizontal rows, XLOOKUP handles both. If your lookup and return arrays are rows instead of columns, it will function as a horizontal lookup automatically.