Excel Table Lookup Functions: Examples and How-To Guide
In this article
Excel table lookup functions allow you to retrieve specific data from a larger dataset based on a unique identifier, such as an ID number or a product name. To achieve this, you primarily use VLOOKUP, XLOOKUP, or INDEX-MATCH. These functions search for a value in one column and return a corresponding value from another column in the same row. To start, you need a structured data range (preferably formatted as an official Excel Table via Ctrl+T) where the unique identifier is located to the left of the data you wish to retrieve.
What You'll Need
- Microsoft Excel (XLOOKUP requires Microsoft 365 or Excel 2021 or newer).
- A source data table containing the information you want to find.
- A lookup value (the specific piece of information you are searching for).
- A clear understanding of which column contains your search key and which contains the result.
Step-by-Step
- Prepare Your Data Table: Ensure your data is organized in columns. For the most reliable results, select your data range and press Ctrl+T to convert it into an official Excel Table. This creates dynamic named ranges, meaning if you add new rows to your data, your lookup formulas will update automatically without needing to change the cell references. Give your table a name in the Table Design tab, such as "EmployeeData".
- Identify the Lookup Value: Decide which cell will hold the value you are searching for. For example, if you have a list of employee IDs in Column A and names in Column B, your lookup value might be an ID number typed into cell E2.
- Using VLOOKUP (The Classic Method):
- Select the cell where you want the result to appear.
- Type
=VLOOKUP(. - Click the cell containing your lookup value (e.g., E2).
- Specify the table array. If you used an official table, type the table name (e.g., "EmployeeData"). If not, highlight the entire range of data.
- Enter the column index number. This is the number of the column containing the result, counting from the left. If your names are in the second column of the table, enter
2. - Enter
FALSEfor an exact match. This is critical; using TRUE may return the closest match instead of the exact one. - Close the parenthesis and press Enter. Example:
=VLOOKUP(E2, EmployeeData, 2, FALSE).
- Using XLOOKUP (The Modern Method):
- Select the result cell and type
=XLOOKUP(. - Select the lookup value (e.g., E2).
- Select the specific column in your table that contains the IDs (the lookup array).
- Select the specific column in your table that contains the names (the return array).
- (Optional) Enter a value to return if no match is found, such as "Not Found".
- Close the parenthesis and press Enter. Example:
=XLOOKUP(E2, EmployeeData[Employee ID], EmployeeData[Employee Name], "Not Found").
- Select the result cell and type
- Using INDEX and MATCH (The Flexible Method):
- Start with the INDEX function:
=INDEX(. - Select the column containing the result you want (e.g., the Name column).
- Type a comma, then type
MATCH(. - Select the lookup value (e.g., E2).
- Select the column containing the IDs.
- Type
, 0)to ensure an exact match for the MATCH function. - Close the final parenthesis for the INDEX function and press Enter. Example:
=INDEX(EmployeeData[Employee Name], MATCH(E2, EmployeeData[Employee ID], 0)).
- Start with the INDEX function:
- Test Your Lookup: Change the value in your lookup cell (E2) to a different ID. The result cell should instantly update to the corresponding name from your table.
Common Mistakes
One of the most frequent errors is forgetting to set the range lookup to FALSE in VLOOKUP. When left blank or set to TRUE, Excel assumes the data is sorted in ascending order and will return the nearest value if an exact match isn't found, leading to incorrect data retrieval.
Another common mistake is including the header row in the VLOOKUP table array but not accounting for it, or conversely, selecting a range that doesn't cover all the data. Using official Excel Tables (Ctrl+T) solves this because the formula refers to the table name rather than specific cell coordinates like A2:B500.
Data type mismatches are also a major hurdle. If your lookup value is stored as text (e.g., "101") but the ID column in your table is stored as a number (101), Excel will return a #N/A error because it does not see them as identical. Ensure both the search key and the source column are formatted as the same data type.
In VLOOKUP, users often try to look up a value to the left of the lookup column. VLOOKUP can only search the leftmost column of the selected range and move to the right. If the ID is in Column B and the name is in Column A, VLOOKUP will fail. This is why XLOOKUP or INDEX-MATCH are preferred for complex sheets.
Tips
To make your lookup functions more robust, wrap them in an IFERROR function. For example, =IFERROR(VLOOKUP(E2, EmployeeData, 2, FALSE), "Invalid ID"). This replaces the ugly #N/A error with a clean, user-friendly message when a search term is not found in the list.
Use Data Validation to create a dropdown menu for your lookup value cell. Go to the Data tab > Data Validation > Allow: List, and select your ID column. This prevents typos and ensures that every value entered into the lookup cell actually exists in your source table.
When working with massive datasets, XLOOKUP is generally more efficient than VLOOKUP. It defaults to an exact match, meaning you don't have to remember to type FALSE, and it doesn't require you to count columns, which reduces the risk of errors if you insert a new column into your table later.
If you need to return multiple columns of data for a single lookup value, XLOOKUP can do this natively. By selecting multiple columns for the return array, XLOOKUP will "spill" the results into adjacent cells automatically, saving you from writing multiple separate formulas.
Troubleshooting
If your formula returns #N/A, first check for leading or trailing spaces in your cells. A cell containing "101 " (with a space) is not the same as "101". You can fix this by using the TRIM function on your data or using Find and Replace (Ctrl+H) to remove all spaces from the ID columns.
If you see a #REF! error, it usually means the column index number in your VLOOKUP is larger than the number of columns in your selected range. For example, if your table has 3 columns and you tell VLOOKUP to return column 4, it will crash. Double-check your column count.
If the formula returns the wrong value, check the range lookup argument in VLOOKUP. If it is missing or set to TRUE, Excel is performing an approximate match. Ensure it is set to FALSE. Also, ensure your lookup value is not duplicated in the source table; lookup functions always return the first match they encounter.
If you see a #NAME? error, you likely misspelled the function name or the name of the Excel Table. Check that "EmployeeData" is spelled exactly as it appears in the Table Design tab and that you haven't missed a parenthesis.
Frequently Asked Questions
Can VLOOKUP find data in another worksheet?
Yes. When selecting the table array, simply click over to the other sheet and highlight the range. Excel will automatically add the sheet name to the formula, such as 'Sheet2'!A2:B100.
What is the difference between VLOOKUP and XLOOKUP?
VLOOKUP only searches the first column and moves right; XLOOKUP can search any column and return a value from any other column (left or right). XLOOKUP also defaults to an exact match and is generally faster.
How do I look up a value based on two different criteria?
The easiest way is to create a "helper column" in your source table that concatenates the two criteria (e.g., =A2&B2). You then perform your lookup against this combined unique key.
Do I have to sort my data before using a lookup function?
Only if you are using an approximate match (TRUE in VLOOKUP). For exact matches, which are used in 99% of business cases, your data can be in any order.
Why is my XLOOKUP not working in my version of Excel?
XLOOKUP is only available in Microsoft 365 and Excel 2021 or later. If you are using Excel 2019 or older, you must use VLOOKUP or INDEX-MATCH instead.
Can I use a lookup function to find a value in a row instead of a column?
Yes, for horizontal data, you can use HLOOKUP. However, XLOOKUP is more versatile and can handle both vertical and horizontal lookups without needing a separate function.