Matching data across two Excel sheets is a common task that allows you to combine information, such as adding prices from a product list to an order form. The most reliable methods for this are the VLOOKUP function, which has been a standard for years, and the newer XLOOKUP function, which offers more flexibility and easier error handling. Before starting, ensure both sheets have a unique identifier column (like ID numbers or email addresses) that exists in both datasets.
What You'll Need
- Two Excel worksheets with overlapping data.
- A unique key column present in both sheets (e.g., Product ID, Employee Number).
- Excel installed on your computer (Microsoft 365, Excel 2021, or later for XLOOKUP; earlier versions require VLOOKUP or INDEX/MATCH).
- Basic knowledge of cell references (A1, B2, etc.).
Step-by-Step
- Prepare your data: Open your Excel workbook containing both sheets. Ensure there are no blank rows or columns within the data tables, as these can break lookup formulas. Identify the "Key Column" in both sheets—the column that contains the unique values you will use to match the rows.
- Choose your method: Decide whether to use VLOOKUP or XLOOKUP. If you are using Microsoft 365 or Excel 2021+, XLOOKUP is recommended because it defaults to exact matches and handles errors gracefully. If you are on an older version, use VLOOKUP.
- Select the destination cell: Go to the sheet where you want the matched data to appear. Click on the first empty cell next to your key column where you want the result to show up.
- Enter the formula (VLOOKUP): Type
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup]). Replacelookup_valuewith the cell reference of the key in the current row (e.g., A2). Fortable_array, select the range in the second sheet that includes the key column and the data column you want to retrieve. Note that the key column must be the first column in this selected range. Setcol_index_numto the number of the column you want to return (counting from left to right within the selected range). Always set[range_lookup]to FALSE for an exact match. - Enter the formula (XLOOKUP): Type
=XLOOKUP(lookup_value, lookup_array, return_array). Setlookup_valueto the key cell (e.g., A2). Setlookup_arrayto the entire key column in the second sheet. Setreturn_arrayto the entire column in the second sheet that contains the data you want to bring over. Optionally, add a fourth argument for "if not found" text, like "Not Found", to avoid #N/A errors. - Lock the ranges: After entering the formula, press F4 to convert relative references to absolute references (adding $ signs) for the table arrays. This ensures that when you copy the formula down, it continues looking at the correct source data rather than shifting down the sheet.
- Fill the formula down: Double-click the fill handle (the small square at the bottom-right corner of the active cell) or drag it down to apply the formula to all rows in your dataset.
- Verify the results: Check a few random entries manually to ensure the data matches correctly between the two sheets.
Common Mistakes
The most frequent error is forgetting to set the last argument in VLOOKUP to FALSE. If omitted, Excel assumes TRUE, which performs an approximate match and requires sorted data, leading to incorrect results. Another common issue is mismatched data types; if one sheet stores IDs as numbers and the other as text, they will not match even if they look identical visually. Finally, users often forget to lock the table array references, causing the lookup range to shift incorrectly when dragging the formula down.
Tips
Use named ranges instead of hard-coded cell references (e.g., name the source table "ProductData") to make formulas easier to read and maintain. If you encounter many errors, try using the TRIM function to remove accidental spaces around your key values, as trailing spaces prevent exact matches. For large datasets, consider using Power Query instead of formulas, as it processes data faster and doesn't slow down the workbook calculation time.
Troubleshooting
If you see #N/A errors, check that the lookup value actually exists in the source table. Use the filter option in the source sheet to search for the specific value. If the value appears to exist but still returns an error, inspect the cells for hidden characters or extra spaces by using the LEN function to compare character counts. If you get #REF! errors, ensure that the columns referenced in your formula haven't been deleted or moved in the source sheet. If the formula works for the first row but fails for others, verify that you used absolute references ($) for the lookup table range.
Frequently Asked Questions
Can I match data if the keys are in different columns?
Yes. With XLOOKUP, you can specify any column as the lookup array and any other column as the return array. With VLOOKUP, the key must be in the first column of the selected table array, so you may need to rearrange your source data or use INDEX/MATCH instead.
Why does my VLOOKUP return the wrong value?
This usually happens if the data isn't sorted when using approximate match (TRUE), or if there are duplicate keys in the source data. VLOOKUP only returns the first match it finds. Ensure you are using FALSE for exact matching and that your keys are unique.
Is XLOOKUP better than VLOOKUP?
XLOOKUP is generally superior because it searches left-to-right and right-to-left without needing the key column to be first, defaults to exact matches, and provides built-in error handling. However, it is only available in newer versions of Excel.
How do I match multiple criteria?
Standard VLOOKUP and XLOOKUP functions typically handle single criteria. To match based on two or more columns, you can create a helper column in both sheets that concatenates the criteria (e.g., =A2&"-"&B2) and then look up against this combined key.