XLOOKUP is the modern replacement for VLOOKUP and HLOOKUP in Excel. It lets you search for a value in one column and return a matching value from any other column, to the left or right, without the limitations of the old functions. In its simplest form, the syntax is =XLOOKUP(lookup_value, lookup_array, return_array). For example, to find the price of a product in cell A2, with product names in A2:A20 and prices in B2:B20, you’d write =XLOOKUP(A2, A2:A20, B2:B20). This guide walks you through using XLOOKUP step by step, including common mistakes, troubleshooting, and tips.
What You’ll Need
- Microsoft Excel 2021 or Microsoft 365 (XLOOKUP is not available in older versions like Excel 2019 or earlier).
- A worksheet with at least two columns of data: one for the lookup value and one for the result you want to return.
- Basic familiarity with entering formulas in Excel.
Step-by-Step
- Identify your data layout. Decide which column contains the value you want to search for (the lookup value) and which column contains the result you want to pull. For instance, if you have product IDs in column A and prices in column B, and you want to find the price for a specific ID, your lookup value is the ID, your lookup array is A:A, and your return array is B:B.
- Select the cell where you want the result. Click on an empty cell, such as D2, where you’ll enter the XLOOKUP formula.
- Type the formula. Start with an equals sign:
=XLOOKUP(. Excel will show a tooltip with the arguments. - Enter the lookup value. This can be a cell reference (e.g.,
C2) or a text value in quotes (e.g.,"A-100"). For this example, typeC2(the cell containing the product ID you’re looking for). - Add a comma, then the lookup array. Select the column that contains the lookup values. For example,
A:AorA2:A20. Type a comma after it. - Add the return array. Select the column from which you want to pull the result. For example,
B:BorB2:B20. Close the parentheses. - Press Enter. The formula will return the matching value. If no match is found, it will return
#N/Aby default. - Optional: Add the “not found” argument. To display a custom message instead of #N/A, add a comma after the return array and type a text string, e.g.,
"Not found". The full formula becomes=XLOOKUP(C2, A2:A20, B2:B20, "Not found"). - Optional: Use match mode and search mode. For exact match (the default), you can omit these. If you need an approximate match (e.g., for tiered pricing), add a comma and use
1for exact or next smaller,-1for exact or next larger,2for wildcard match. For search mode,1is first-to-last,-1is last-to-first,2is binary ascending,-2is binary descending. Example:=XLOOKUP(C2, A2:A20, B2:B20, , -1, 1)for last-to-first exact match. - Copy the formula down if needed. If you have multiple lookup values, drag the fill handle down to copy the formula to other cells, adjusting references as needed.
Common Mistakes
- Using the wrong column order. Unlike VLOOKUP, XLOOKUP doesn’t require the lookup column to be the first column. But you must ensure the lookup array and return array are aligned correctly—same number of rows.
- Forgetting the comma separators. In some locales, you may need semicolons instead of commas. Check your Excel settings; the formula must use the list separator your region uses.
- Not locking references when copying. If you copy the formula down, relative references change. Use absolute references (e.g.,
$A$2:$A$20) if you want the lookup range to stay fixed. - Assuming XLOOKUP works in older Excel. If you share the workbook with someone using Excel 2019 or earlier, they’ll see a #NAME? error. Check compatibility.
- Using wildcards without match mode 2. If you want to use wildcards (* or ?), you must set match mode to 2, otherwise they’re treated as literal characters.
Tips
- Use XLOOKUP instead of VLOOKUP for new workbooks. It’s simpler, faster, and can return multiple columns if you use an array formula (e.g.,
=XLOOKUP(C2, A2:A20, B2:D20)returns three columns when entered in a range). - Combine with IFERROR for extra control. While XLOOKUP has a built-in “not found” argument, wrapping it in IFERROR can handle other errors like #VALUE!.
- Use whole columns (e.g., A:A) for dynamic data. This ensures new rows are included automatically, but it can slow down large files. Prefer defined ranges for speed.
- Sort data for binary search. If you’re doing many lookups on a large dataset, set search mode to 2 or -2 (binary) to speed up calculations, but ensure the lookup array is sorted accordingly.
- Use XLOOKUP for left lookups. Unlike VLOOKUP, you can return values to the left of the lookup column without rearranging data.
Troubleshooting
- #NAME? error: This means your Excel version doesn’t support XLOOKUP. Upgrade to Microsoft 365 or Excel 2021, or use VLOOKUP/INDEX-MATCH as a fallback.
- #N/A error: This is the default when no match is found. Check that the lookup value exists in the lookup array, and that there are no extra spaces or text formatting differences. Use the TRIM function on your data.
- #VALUE! error: Usually indicates a mismatch in array sizes. Ensure your lookup array and return array have the same number of rows.
- #REF! error: This can occur if you delete a column that’s part of the return array. Check your formula references.
- Incorrect results: If you get a wrong value, check the match mode. For exact matches, leave it blank or use 0. If you used 1 or -1, Excel may return an approximate match.
- Formula works but returns wrong column: Double-check that your return array is the correct column. It’s easy to select the wrong range when clicking.
Frequently Asked Questions
Q: Can XLOOKUP return multiple columns?
Yes. If you select a range for the return array (e.g., B2:D20) and enter the formula normally, it will return the first value. To spill multiple results, select multiple cells horizontally and enter the formula as an array (Ctrl+Shift+Enter in older Excel, or just Enter in Microsoft 365).
Q: What’s the difference between XLOOKUP and VLOOKUP?
XLOOKUP can look to the left, has a built-in “not found” message, supports wildcards, and doesn’t require the lookup column to be the first. VLOOKUP only looks right and requires exact or approximate match with a separate range_lookup argument.
Q: Does XLOOKUP work in Excel for Mac?
Yes, XLOOKUP is available in Excel for Microsoft 365 on Mac. The syntax is identical, but note that the list separator may be a semicolon in some European locales.
Q: Can I use XLOOKUP with wildcards?
Yes, set match mode to 2 in the fourth argument. For example, =XLOOKUP("A*", A2:A20, B2:B20, , 2) finds the first value starting with “A”.
Q: What if my lookup value is a number stored as text?
XLOOKUP treats numbers and text differently. If your lookup array contains numbers and your lookup value is text (or vice versa), you’ll get #N/A. Convert the lookup value using VALUE() or TEXT() to match the data type.
Q: Is XLOOKUP faster than VLOOKUP?
Generally, XLOOKUP is faster because it doesn’t scan the entire table and uses optimized search algorithms. For large datasets, the performance difference is noticeable.
Related
- Does Google Sheets Have XLOOKUP? How to Use It
- XLOOKUP in Google Sheets: How It Works and When to Use It
- XLOOKUP in Google Sheets: How It Works and When to Use It
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Rank in Excel Without Duplicates: Formula and TipsYes. To give every numeric value its own rank, including tied values, add a tie-break count to Excel’s…
- C++ String Library Functions and How to Use ThemC++ string library functions are the standard tools for creating, measuring, changing, searching, comparing, and converting text. Most…
- How to Round Down in Excel: Formulas, Steps, and ExamplesTo round a value down in Excel, use the ROUNDDOWN function. If A2 contains 12.987 and you want…
- Excel QR Code Formula: Create QR Codes from Cell DataExcel has no built-in QR-code function, but in Microsoft 365 for Windows you can display a QR code…
- EDATE in Excel: Add Months, Not DaysEDATE in Excel moves a date by whole calendar months; it does not add a specified number of…
- First Quartile in Excel: Find It With a Simple FormulaTo find the first quartile (Q1) in Excel, use =QUARTILE.INC(A2:A9,1) when your numeric data is in A2:A9. The…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.