XLOOKUP is Excel's modern replacement for VLOOKUP and HLOOKUP. It lets you find a value in a column or row and return a matching value from any other column or row, with a simpler syntax and no tricky workarounds. This guide walks you through using XLOOKUP from scratch, with real examples, common pitfalls, and fixes. You'll need Excel 2021 or Microsoft 365 (XLOOKUP is not available in older versions).
What You'll Need
- Excel 2021 or Microsoft 365 (desktop or web). If you're not sure, type
=XLOOKUP(in a cell – if you see a function tip, you have it. - A worksheet with at least two columns: one to search in (e.g., Product ID) and one to return from (e.g., Price).
- Basic familiarity with entering formulas in Excel (typing
=and selecting cells).
Step-by-Step
- Understand the syntax. XLOOKUP takes three required arguments and three optional ones:
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])The first three are all you need for most tasks. - Pick your lookup value. This is the thing you want to find – a product ID, a name, a code. It can be a cell reference (like
E2) or a typed value (like"A-100"). - Select the lookup array. This is the column or row where Excel will search for that value. It must be a single column or single row – not a whole table. For example,
B:BorB2:B100. - Select the return array. This is the column or row that holds the value you want to get back. It must be the same size as the lookup array. For example, if you searched in
B:B, you can return fromD:D. - Write the formula. In a cell, type
=XLOOKUP(E2, B:B, D:D)and press Enter. Excel returns the matching value from column D for the lookup value in E2. If no match exists, you'll see #N/A. - Add a friendly "not found" message. Use the fourth argument:
=XLOOKUP(E2, B:B, D:D, "Not found"). Now if there's no match, you get the text instead of an error. - Do an approximate match (like VLOOKUP's TRUE). The fifth argument,
match_mode, is 0 for exact match (default), -1 for exact or next smaller, 1 for exact or next larger, and 2 for wildcard. For example, to find the tax rate for a salary where the table lists brackets, use=XLOOKUP(E2, B:B, D:D, "No bracket", -1). - Search from the bottom (like VLOOKUP with range_lookup FALSE but from last). The sixth argument,
search_mode, is 1 for first-to-last (default), -1 for last-to-first, 2 for binary search (sorted ascending), and -2 for binary search (sorted descending). Use -1 to get the most recent entry in a log. - Return multiple columns at once. Instead of a single return column, you can specify a range of columns (e.g.,
D:F) and XLOOKUP will spill all matching columns into adjacent cells. This works automatically in Excel 365. - Use XLOOKUP for two-way lookups. Combine it with another XLOOKUP to find a value at the intersection of a row and column. For example,
=XLOOKUP(G2, A:A, XLOOKUP(H2, B1:F1, B2:F100))finds the sales figure for a product (G2) in a given month (H2).
Common Mistakes
- Using the wrong lookup array size. The lookup and return arrays must be the same size. If you use
B2:B100andD2:D50, you'll get a #VALUE! error. - Forgetting that XLOOKUP is exact match by default. Unlike VLOOKUP (which defaults to approximate), XLOOKUP defaults to exact. If you need an approximate match, you must set
match_modeto -1 or 1. - Not handling #N/A. When a value isn't found, Excel shows #N/A. Use the
if_not_foundargument to show a friendly message instead. - Assuming XLOOKUP works left-to-right only. Unlike VLOOKUP, XLOOKUP can return columns to the left of the lookup column. That's a feature, not a mistake – but some users still try to reorder data unnecessarily.
- Using whole columns with binary search. Binary search modes (2 and -2) require the data to be sorted. If it isn't, you'll get wrong results. Stick to default search unless you're sure.
Tips
- Use table references. If your data is in an Excel Table (Insert > Table), you can use structured references like and Table1[Price] . This makes formulas easier to read and automatically adjusts when you add rows.
- Combine with IFERROR for older Excel compatibility. If you share files with people using older Excel, wrap XLOOKUP in IFERROR:
=IFERROR(XLOOKUP(...), "Not found"). But note that IFERROR won't help if the other person's Excel doesn't have XLOOKUP at all. - Use XLOOKUP to replace INDEX-MATCH. For most cases, XLOOKUP is simpler. But INDEX-MATCH is still useful for very complex lookups (like multiple criteria without concatenation).
- Leverage the spill behavior. When you return multiple columns, Excel spills the results automatically. Make sure there's empty space to the right, or you'll get a #SPILL! error.
- Press F4 to lock references. When copying the formula down, you often want the lookup and return arrays to stay fixed. Use absolute references (like
$B$2:$B$100) or table references.
Troubleshooting
If your XLOOKUP returns an error, here's what to check in order:
- #N/A – value not found. First, verify the lookup value exists in the lookup array. Check for extra spaces, different data types (text vs. number), or hidden characters. Use the TRIM function to clean data:
=TRIM(A2). If the lookup value is a number stored as text, tryVALUE(E2)or multiply by 1. - #VALUE! – array size mismatch. Make sure the lookup array and return array have the same number of rows (or columns if horizontal). For example, if you use
B2:B100as lookup, return must also have 99 cells, likeD2:D100. - #SPILL! – not enough space. If you're returning multiple columns, clear any cells that would overlap with the spill range. Or use
@to force a single result (but that defeats the purpose). - #NAME? – function not recognized. This means your Excel version doesn't support XLOOKUP. Upgrade to Microsoft 365 or Excel 2021, or use VLOOKUP/INDEX-MATCH instead.
- Wrong results (not an error). If you get a value but it's not the one you expected, check the match_mode. If you used -1 or 1, the data might not be sorted as required for approximate match. Also check if you accidentally swapped lookup and return arrays.
Frequently Asked Questions
Can XLOOKUP replace VLOOKUP completely?
Yes, for most lookups. XLOOKUP can return values from any column (left or right), handle errors gracefully, and do approximate matches. The only exceptions are if you need to work with older Excel versions or use some very specific array formulas.
How do I use XLOOKUP with multiple criteria?
You can concatenate the criteria into a single lookup value. For example, =XLOOKUP(E2&F2, A:A&B:B, C:C) where E2 and F2 are the two criteria and A:A/B:B are the corresponding columns. This works because Excel concatenates the arrays element-wise.
What's the difference between XLOOKUP and INDEX-MATCH?
XLOOKUP is simpler and more intuitive. INDEX-MATCH is more flexible for complex scenarios (like returning a whole row or column, or when you need to perform calculations on the lookup array). For most users, XLOOKUP is the better choice.
Does XLOOKUP work in Excel Online or Google Sheets?
XLOOKUP works in Excel for the web (part of Microsoft 365). Google Sheets has its own function called VLOOKUP, but you can use XLOOKUP in Google Sheets if you enable the "XLOOKUP" function from the Google Workspace Marketplace – but it's not native. For Sheets, consider using VLOOKUP or INDEX-MATCH.
Why is my XLOOKUP returning #N/A even though the value exists?
This usually happens due to data type mismatch. For example, the lookup value is a number but the lookup array contains text numbers. Use the TEXT function to convert one to the other, or use the VALUE function. Also check for extra spaces or non-printable characters.
Can I use XLOOKUP to return a whole row or column?
Yes. If you set the return_array to a whole row (e.g., B1:F1) or a whole column (e.g., B:B), XLOOKUP will return that entire row/column as a spill range. This is useful for extracting a full record.