Excel XLOOKUP Formula for a Table: Step-by-Step Guide
In this article
To use XLOOKUP on a table, you need three things: the lookup value, the column or range that contains it, and the column or range that contains the result. The formula is =XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode]) . Point the lookup array at the table column that holds the key (for example, a product ID) and the return array at the table column that holds the answer (for example, a price). If you are looking up inside a formatted Excel Table, you can use structured references such as and Table1[Price] , or ordinary cell ranges. XLOOKUP is available in Excel for Microsoft 365, Excel 2021 and later, and Excel for the web; it is not in Excel 2019 or older, where you would use INDEX and MATCH instead.
What You'll Need
- A version of Excel that supports XLOOKUP: Microsoft 365, Excel 2021 or later, or Excel for the web. If you type the formula and Excel returns
#NAME?, your version does not have it. - A data range or an Excel Table with a clear key column (the column you search in) and at least one result column.
- Consistent data types in the key column: text that looks like a number (for example, IDs stored as text) will not match a real number, and vice versa.
Step-by-Step
- Set up your table. Select your data and press Ctrl+T (Cmd+T on Mac) to convert it to an Excel Table, or leave it as a plain range. A formatted Table gives you structured references and automatically expands when you add rows. Give the table a name in Table Design if you want to refer to it easily.
- Pick the cell for the result. Click the cell where the answer should appear, for example next to the lookup value you typed.
- Start the formula. Type
=XLOOKUP(. Excel will show the argument names as a tooltip. - Enter the lookup value. This is the value you want to find, such as a cell reference like
A2or a literal like"P-104". Follow it with a comma. - Enter the lookup array. Select the column in the table that contains the key. With a formatted Table, click the column header; Excel inserts something like . With a plain range, select the cells, for example $A$2:$A$100 . Use absolute references (dollar signs) if you plan to copy the formula down.
- Enter the return array. Select the column that contains the value you want back, for example
Table1[Price]or$C$2:$C$100. The return array should be the same height as the lookup array; XLOOKUP returns the value from the same row position. - Add optional arguments if needed. The fourth argument,
if_not_found, lets you show a friendly message instead of#N/A, for example"Not found". The fifth argument,match_mode, controls exact versus approximate matching: 0 is exact (the default), -1 is exact or next smaller, 1 is exact or next larger, and 2 enables wildcards. The sixth argument,search_mode, controls search direction: 1 searches first to last (default), -1 searches last to first, 2 is a binary search ascending, and -2 is binary descending. For most table lookups, leave both at their defaults. - Close the formula and press Enter. A complete example: . This searches the Product ID column for the value in A2 and returns the matching Price.
- Copy the formula down. Drag the fill handle or copy and paste. If you used structured references, the formula stays readable; if you used ranges, make sure the lookup and return arrays are locked with absolute references so they do not shift.
- Check the result. Compare a few answers against the source table manually. If you see
#N/A, the lookup value is not present; if you see#VALUE!, the arrays are mismatched in size or the data types differ.
Common Mistakes
- Mismatched array sizes. The lookup array and return array must have the same number of rows. Selecting a full column for one and a limited range for the other causes errors or wrong answers.
- Forgetting absolute references. When copying a formula down with plain ranges, relative references shift and start returning the wrong row. Lock them with
$or use a Table. - Text versus number mismatches. A lookup value stored as text (often left-aligned) will not match a number stored as a number. Use
VALUE()or clean the data so both sides match. - Hidden spaces. Trailing spaces in the key column cause
#N/A. UseTRIM()on the lookup value or clean the source data. - Using approximate match by accident. Setting
match_modeto -1 or 1 without sorted data returns unexpected results. Leave it at 0 for exact matches unless you specifically need a bracket lookup. - Assuming XLOOKUP exists everywhere. Older Excel versions and some third-party spreadsheet apps do not support it. The formula will show
#NAME?.
Tips
- Use structured references (
Table1[Column]) so formulas stay readable and expand automatically as the table grows. - Add the
if_not_foundargument to avoid ugly#N/Aerrors in reports; a blank""or a message like"Check ID"works well. - XLOOKUP can return an entire row or multiple columns at once if the return array spans several columns; this spills results across cells in Microsoft 365 and Excel 2021.
- To return a value from a column to the left of the key, XLOOKUP handles it directly, unlike VLOOKUP, which only looks right.
- For a case-sensitive lookup, combine XLOOKUP with the
EXACTfunction inside the lookup array, or useXMATCHwith match mode 0 and a helper column. - If you need to look up in a different workbook, include the workbook and sheet name in the reference, and keep both files open while editing.
Troubleshooting
If the formula returns #N/A , first confirm the lookup value exists exactly as typed. Check for extra spaces, different capitalization (XLOOKUP is not case-sensitive by default), or numbers stored as text. Use =TRIM(A2) and =ISNUMBER(A2) to test. If the formula returns #VALUE! , the lookup and return arrays likely have different row counts; reselect them so both cover the same rows. If you see #NAME? , your Excel version does not support XLOOKUP; use INDEX and MATCH instead, for example . If the formula returns the wrong row, check that both arrays start on the same row; XLOOKUP matches by position, so a one-row offset shifts every result. If copying the formula produces errors, inspect the references for missing dollar signs. Finally, if the table has a filter applied, XLOOKUP still searches all rows, not just visible ones; use SUBTOTAL or FILTER if you need visible-only results.
Frequently Asked Questions
Can XLOOKUP search a whole table at once?
Yes. Set the lookup array to the key column and the return array to the column you want. To return multiple columns, select a multi-column return array; the results spill across adjacent cells in supported versions.
Does XLOOKUP work with Excel Tables?
Yes, and it works best with structured references such as . The formula updates automatically when rows are added to the table.
Why does XLOOKUP return #N/A when the value is clearly there?
Usually a data-type mismatch: one side is text, the other a number, or there are hidden spaces. Clean both sides or use TRIM and VALUE to normalize.
Is XLOOKUP better than VLOOKUP for tables?
For most table lookups, yes: it can look left, defaults to exact matching, and does not require counting columns. VLOOKUP remains useful in older files or when you need compatibility with Excel 2019 and earlier.
Can I use XLOOKUP to find the last match instead of the first?
Yes. Set the sixth argument (search_mode) to -1 to search from last to first. This is handy when a table contains duplicate keys and you want the most recent entry.
What happens if the lookup value is not found?
Without the if_not_found argument, XLOOKUP returns #N/A. Supply a fourth argument such as "Not found" or "" to control the output.