Excel Formula Lookup: How to Use VLOOKUP and XLOOKUP
In this article
An Excel lookup formula allows you to search for a specific value in one part of a spreadsheet and return a corresponding piece of information from another column or row. To do this, you typically use the VLOOKUP function or the newer, more flexible XLOOKUP function. These tools eliminate the need to manually scan thousands of rows to find a matching piece of data, such as looking up a customer's email address using their Order ID.
What You'll Need
- Microsoft Excel (Desktop version or Excel for the Web).
- A dataset organized in a table or range where one column contains a unique identifier (e.g., ID numbers, SKU, or Email).
- A "Lookup Value" (the specific piece of information you already know and want to search for).
Step-by-Step
Depending on your version of Excel, you will use either XLOOKUP (available in Microsoft 365 and Excel 2021+) or VLOOKUP (available in all versions). XLOOKUP is the modern standard, but VLOOKUP remains essential for compatibility with older files.
Option 1: Using XLOOKUP (Recommended)
- Select the cell where you want the result to appear.
- Type the formula start: Enter
=XLOOKUP(. - Select the Lookup Value: Click the cell that contains the value you are searching for (e.g., cell A2 which contains an Employee ID), then type a comma.
- Select the Lookup Array: Highlight the column in your data table that contains the IDs. This is where Excel will search for the match. Type a comma.
- Select the Return Array: Highlight the column that contains the information you want to retrieve (e.g., the "Employee Name" column).
- Close and Enter: Type a closing parenthesis
)and press Enter.
Option 2: Using VLOOKUP
- Select the cell where you want the result to appear.
- Type the formula start: Enter
=VLOOKUP(. - Select the Lookup Value: Click the cell containing the value you are searching for, then type a comma.
- Select the Table Array: Highlight the entire range of your data table. Crucial: The column containing your lookup value must be the leftmost column in this selection. Type a comma.
- Enter the Column Index Number: Count the columns in your selection from left to right. If the data you want to return is in the third column of your selection, type
3. Type a comma. - Set the Range Lookup: Type
FALSEto ensure Excel finds an exact match. Type a closing parenthesis)and press Enter.
Common Mistakes
- Wrong Column Index (VLOOKUP): Counting the column index based on the entire spreadsheet rather than the specific range selected in the formula.
- Omitting "FALSE" (VLOOKUP): If you leave the fourth argument blank or set it to TRUE, Excel may return an approximate match, which often results in the wrong data being returned if the list isn't sorted.
- Lookup Value not in the First Column (VLOOKUP): VLOOKUP cannot look "to the left." If your unique ID is in Column B and you want data from Column A, VLOOKUP will fail. Use XLOOKUP instead.
- Data Type Mismatch: Searching for a number stored as text. If your ID is "123" (text) but your lookup value is 123 (number), Excel will not see them as a match.
Tips
- Use Absolute References: When dragging a lookup formula down a column, press
F4while selecting your arrays/ranges to add dollar signs (e.g.,$A$2:$B$100). This locks the table in place so the range doesn't shift. - Named Ranges: Instead of highlighting A2:B500 , highlight the area and name it "EmployeeTable" in the top-left Name Box. Your formula becomes much easier to read: .
- Handle Missing Data: XLOOKUP has a built-in "if not found" argument. You can add a message like
=XLOOKUP(A2, B:B, C:C, "Not Found")to avoid ugly error codes.
Troubleshooting
If your formula is not returning the expected result, try these steps in order:
- Check for Leading/Trailing Spaces: A cell that looks like "101" might actually be "101 ". Use the
=TRIM()function to clean your data. - Verify Data Types: Ensure both the lookup value and the source column are formatted the same (both as General, both as Number, or both as Text).
- Check for #N/A Errors: This usually means the value simply does not exist in the search column. Double-check the spelling or the ID number.
- Check for #REF! Errors: This happens in VLOOKUP if your Column Index Number is higher than the number of columns you selected in your range.
- Verify the Leftmost Column: If using VLOOKUP, ensure the value you are searching for is in the very first column of the highlighted range.
Frequently Asked Questions
What is the difference between VLOOKUP and XLOOKUP?
VLOOKUP only searches from left to right and requires a column index number. XLOOKUP can search in any direction, does not require counting columns, and is generally more resilient when columns are added or deleted from a sheet.
Can I look up data from a different worksheet?
Yes. When selecting the Lookup Array or Table Array, simply click over to the other tab/sheet and highlight the range. Excel will automatically add the sheet name to the formula (e.g., 'Sheet2'!A2:B100).
How do I look up a value based on two different criteria?
While VLOOKUP cannot do this easily, XLOOKUP can. You can use the ampersand (&) to join criteria, such as =XLOOKUP(A2&B2, Range1&Range2, ReturnRange).
Why is my VLOOKUP returning the wrong row?
This is almost always because the fourth argument (Range_lookup) was omitted or set to TRUE. Ensure the formula ends with , FALSE)` to force an exact match.
Does XLOOKUP work in older versions of Excel?
No. XLOOKUP is only available in Microsoft 365 and Excel 2021 or newer. If you are sharing a file with someone using Excel 2016 or 2019, use VLOOKUP or INDEX/MATCH to ensure the formulas work for them.