Excel Formula to Return Value from Table: Step-by-Step
In this article
To return a value from an Excel table, the simplest reliable method is to use a lookup function that matches a key in one column and returns a value from another. For most modern Excel versions, that means XLOOKUP (Excel 365 and Excel 2021+): =XLOOKUP(lookup_value, lookup_array, return_array). If you are on an older version, use INDEX and MATCH together, or VLOOKUP with an exact match. All three work with Excel Tables (ListObjects), and structured references make the formulas easier to read and maintain.
What You'll Need
- Excel 365, Excel 2021, or Excel 2019 (or an older version that supports INDEX/MATCH). XLOOKUP requires Excel 365 or Excel 2021 and later; it is not available in Excel 2019 or earlier.
- A data range formatted as an Excel Table (select the range and press Ctrl+T, or go to Insert > Table). This is optional but recommended because structured references auto-expand and are less error-prone.
- At least one column of unique identifiers (such as a product code, employee ID, or name) to look up against.
- A separate cell or sheet where you want the returned value to appear.
Step-by-Step
- Format your data as a table. Select any cell inside your data range, press Ctrl+T (Windows) or Command+T (Mac), confirm the range and that “My table has headers” is ticked, then click OK. On the Table Design tab, give the table a meaningful name in the Table Name box (for example,
SalesData). This name is what you will use in formulas. - Decide your lookup value and return column. For example, you might want to look up a product code in the “Code” column and return the matching “Price” from the same row. Write down the exact header names—they must match what you type in the formula.
- Enter the XLOOKUP formula (Excel 365 / 2021+). Click the cell where the result should appear and type:
=XLOOKUP([@Code], SalesData[Code], SalesData[Price])
Here[@Code]refers to the value in the current row’s Code column (if you are inside the table). If you are outside the table, replace it with a cell reference such asG2. The second argument is the column to search, and the third is the column to return. Press Enter. - Enter the INDEX/MATCH formula (older Excel versions). If XLOOKUP is not available, use:
=INDEX(SalesData[Price], MATCH(G2, SalesData[Code], 0))
This searches for the value in G2 within the Code column and returns the corresponding value from the Price column. The0at the end of MATCH forces an exact match. - Use VLOOKUP as a fallback (if your lookup column is the first column of the table). Type:
=VLOOKUP(G2, SalesData, 3, FALSE)
The3is the column number within the table (count from the left, including the lookup column).FALSEensures an exact match. This only works when the lookup column is the leftmost column of the table. - Copy the formula down. Drag the fill handle or copy and paste the formula into the rows below. If you used structured references like
[@Code]inside the table, Excel automatically adjusts the row reference for each row. If you used a fixed cell likeG2, make sure it is a relative reference (no dollar signs) so it changes per row. - Test with a known value. Type a value you know exists in the lookup column into the input cell and confirm the formula returns the correct result. Then type a value that does not exist and check that you get a clear error or a blank (see the Tips section for handling errors).
Common Mistakes
- Using approximate match by mistake. VLOOKUP defaults to approximate match if you omit the fourth argument; always type
FALSEor0for exact match. MATCH also needs0as its third argument. - Mismatched header names. Structured references like
SalesData[Price]are case-insensitive but must match the header text exactly, including spaces. A trailing space in a header will break the formula. - Wrong column index in VLOOKUP. The column number counts from the first column of the table, not from the lookup column. If your table starts at column B and the return column is D, the index is 3, not 4.
- Forgetting to lock the table name or ranges. If you copy a formula to another sheet, structured references stay valid, but plain ranges like
A2:C100need absolute references ($A$2:$C$100) to avoid shifting. - Leaving blank rows inside the table. Blank rows can cause lookups to return 0 or unexpected results. Remove blank rows or use a dynamic array formula that ignores blanks.
- Typing the table name incorrectly. Table names cannot contain spaces; if you named it “Sales Data”, Excel will reject it. Use underscores or no spaces.
Tips
- Handle missing values gracefully. XLOOKUP has a fourth argument for “if not found”:
=XLOOKUP(G2, SalesData[Code], SalesData[Price], "Not found"). For INDEX/MATCH, wrap in IFERROR:=IFERROR(INDEX(...), "Not found"). - Return multiple columns at once. XLOOKUP can return an array if you give it a multi-column return range, for example
=XLOOKUP(G2, SalesData[Code], SalesData[[Price]:[Stock]]). This spills results across adjacent cells in Excel 365. - Use the “@” symbol correctly. Inside a table,
[@Column]refers to the current row; outside a table, use a normal cell reference likeG2. - Prefer XLOOKUP when available. It searches in any direction, defaults to exact match, and handles errors more cleanly than VLOOKUP.
- Name your tables meaningfully. Short, descriptive names like
ProductsorEmployeesmake formulas easier to read and audit. - Convert the result to a value if needed. If you plan to delete the source table, copy the formula results and paste as values to keep the numbers.
Troubleshooting
- #N/A error: The lookup value was not found. Check for typos, extra spaces (use TRIM), or number stored as text versus number. Also confirm the lookup column is the one you think it is.
- #REF! error: The return column reference is invalid, often because the table was resized or a column was deleted. Rebuild the formula using the current table headers.
- #VALUE! error: One of the arguments is the wrong type—for example, a text value where a number is expected. Check that the lookup value matches the data type in the lookup column.
- Formula returns 0 or blank unexpectedly: The matching cell in the return column is empty, or the lookup is matching an empty cell. Use IF to test for blanks, or filter out blank rows.
- Formula works in one row but not others: Check that relative references are correct. If you used
$G$2, every row will look up the same value. Remove the dollar signs from the row part. - Table name not recognized: Go to Table Design and confirm the exact name. Table names cannot contain spaces or special characters other than underscore.
- XLOOKUP not available: Your Excel version may be older than 365 or 2021. Use INDEX/MATCH instead; it works in all versions.
Frequently Asked Questions
Can I use XLOOKUP with an Excel Table?
Yes. XLOOKUP works perfectly with structured references. Use the table name and column headers, for example =XLOOKUP(G2, SalesData[Code], SalesData[Price]). The formula will automatically include new rows added to the table.
What is the difference between VLOOKUP and INDEX/MATCH?
VLOOKUP can only look to the right of the lookup column and requires a column index number. INDEX/MATCH can look in any direction and is more flexible when columns are inserted or moved. Both work with tables, but INDEX/MATCH is generally more robust.
Why does my formula return #N/A when the value clearly exists?
Common causes are trailing spaces in the lookup value or the table data, numbers stored as text in one place and as numbers in another, or a non-printing character. Use =TRIM() or =CLEAN() to clean the values, and check the cell format (General vs Text).
Can I return a value from a different sheet using a table?
Yes. If the table is on another sheet, refer to it by its table name only—Excel does not require the sheet name when using structured references. For example, =XLOOKUP(G2, SalesData[Code], SalesData[Price]) works even if SalesData is on a different worksheet.
How do I handle duplicate values in the lookup column?
XLOOKUP and VLOOKUP return the first match by default. If duplicates exist, the result may not be the one you expect. To return the last match with XLOOKUP, add ,-1 as the sixth argument (search mode). For INDEX/MATCH, you would need a more complex formula or to remove duplicates first.
Does XLOOKUP work in Excel 2019?
No. XLOOKUP is available only in Excel 365 and Excel 2021 and later. In Excel 2019 and earlier, use INDEX/MATCH or VLOOKUP instead.