Matching data between two Excel sheets is straightforward once you know how to align columns, apply formulas, or use built-in tools. This works for consolidating lists, merging records, or finding duplicates—whether you’re comparing inventory, customer records, or financial reports. You’ll only need your Excel software (Excel 2016+ or Google Sheets) and patience for a few clicks or keystrokes. The key is identifying matching keys (like IDs or names) and using conditional logic to link corresponding rows.
What You'll Need
- A copy of Microsoft Excel (2016 or later) or Google Sheets
- Two open Excel files—Sheet A (your source data) and Sheet B (the target or reference data)
- Matching criteria: a common column (e.g., "Employee ID", "Product Name") to pull data from one sheet into another
- Basic familiarity with Excel functions (VLOOKUP, INDEX-MATCH, or CTRL+D for auto-fill)
- Optional: Power Query (Excel’s built-in data transformation tool) or Google Sheets’ "Data > Merge Rows" feature
Step-by-Step
-
Choose a matching key:
- Open both files side by side. Inspect Sheet A and Sheet B for a column with identical values across rows—this will be your "key" (e.g., "Product Code", "Client Number"). Avoid strings (like names) if precision is critical; numeric or alphanumeric keys work best. Label this column in Sheet A as "Match Key" for clarity.
- Example: If Sheet A has "Product ID" and Sheet B has "Product Code", ensure both columns contain the same values for matching. Some fields (like dates) may need formatting adjustments (e.g., "MM/DD/YYYY" vs. "DD-MMM-YY").
-
Method A: Manual Copy-Paste with Formulas (Best for simple 1:1 matches)
- In Sheet B, select the next column (e.g., "Details") where you’ll paste data from Sheet A. For example, if Sheet A’s "Product Name" is in Column D, drag Column E in Sheet B to the right.
- Copy the entire range of matching keys from Sheet A (e.g., select Columns B:B in Sheet A). Paste them into Sheet B’s column for the same key (e.g., Column B in Sheet B).
- In the target column (e.g., Column E in Sheet B), use a formula to pull data from Sheet A:
=IFERROR(INDEX(A:Z, MATCH(B2, A:A, 0)), "")ReplaceA:Zwith Sheet A’s range (e.g., D:D for "Product Name") andB2with the key cell in Sheet B. Drag the formula down to apply it to all rows. - If keys don’t exist in Sheet B, use
IFERRORto return an empty cell instead of an error. For multiple columns in Sheet A, adjust the formula to reference each field separately.
IFERROR(INDEX(...), SEARCH(...))or Google Sheets’FILTERfunction. -
Method B: VLOOKUP (Excel-only, for exact matches)
- Select the cell where you’ll display Sheet A’s data in Sheet B (e.g., E2). Enter:
=VLOOKUP(B2, SheetA!A:Z, 4, FALSE)ReplaceB2(key cell) with your key column,SheetA!A:Z(Sheet A’s range), and4(column number of the data you want to pull). - Drag the formula down. For exact matches, use
FALSE(exact match) instead of0(approximate). - If keys are in different columns or formats, adjust the range (e.g.,
SheetA!D:Dfor "Product Name" instead of Column A).
INDEX-MATCH:=INDEX(SheetA!D:D, MATCH(B2, SheetA!A:A, 0), 1)(Reference the same key column and adjust the second1to pull the desired data column.) - Select the cell where you’ll display Sheet A’s data in Sheet B (e.g., E2). Enter:
-
Method C: Power Query (Excel’s advanced tool)
- In Excel, go to Data > Get & Transform > From Table/Range to load Sheet A’s data into Power Query. Repeat for Sheet B.
- In Power Query for Sheet A, rename the key column (e.g., "Match Key"). In Sheet B’s query, rename its key column similarly.
- Merge the two queries on the match key:
- Right-click the key column in Sheet A’s query > Merge Queries > Sheet B’s query.
- Select the key columns and click Duplicate columns to keep both keys.
- Expand the merged columns to show all data from both sheets.
- Load the merged data back into a new sheet. Power Query handles mismatches automatically (e.g., empty cells for unmatched keys).
-
Method D: Google Sheets (Merge Rows)
- Open both sheets in Google Sheets. In Sheet B, select the column where you want to pull data from Sheet A (e.g., Column E).
- Go to Data > Merge Rows > Merge All. Choose Match Existing Entries Only if exact matches are required.
- Enter the key column (e.g., Column B in Sheet B) as the "Merge Key". Select the corresponding column in Sheet A (e.g., Column A).
- Click Merge. Google Sheets will fill Sheet B’s target column with matching data from Sheet A. For partial matches, use Merge with Partial Matches.
-
Verify results:
- Check for empty cells or errors (e.g., #N/A) in Sheet B’s merged data. Use
IFERRORor Power Query’s merge settings to handle missing matches. - Compare a sample of rows manually to confirm accuracy. If keys are numeric or alphanumeric, ensure formats match (e.g., "123" vs. "00123").
- For duplicates, use Excel’s
COUNTIForSUMIFto check frequency:=COUNTIF(SheetA!A:A, B2)(Replace the range with your key column and Sheet A’s data range.)
- Check for empty cells or errors (e.g., #N/A) in Sheet B’s merged data. Use
Common Mistakes
- Using wrong key columns: Ensure the key columns in both sheets are identical in format (e.g., "ID" vs. "ID#"). A mismatch will break all matches.
- Ignoring case sensitivity: Excel’s VLOOKUP is case-sensitive by default. For case-insensitive matches, use
VLOOKUP(B2, SheetA!A:Z, 4, TRUE)(replaceTRUEwithFALSEfor exact matches). - Skipping formula validation: Always test formulas with a small subset of data. Use
IFERRORto avoid blank screens or errors. - Overlooking data formatting: Dates, currencies, or percentages must match exactly (e.g., "1/1/2024" vs. "01-Jan-24"). Convert formats if needed (e.g., use
TEXTorVALUEfunctions). - Assuming partial matches work: Google Sheets’ "Merge with Partial Matches" is forgiving, but Excel’s methods require exact matches for reliability.
Tips
- Pre-filter data: Use Excel’s
FILTERfunction or Google Sheets’ "Filter" feature to narrow Sheet A to only rows with keys you want to match before merging. - Save as a template: Create a template with standard columns and formulas to reuse across projects.
- Use conditional formatting: Highlight mismatched keys in Sheet B with a green/red color scale (e.g.,
=IFERROR(...)with conditional formatting rules). - Automate with macros (Excel only): For repetitive tasks, record a macro that runs your VLOOKUP or INDEX-MATCH logic. Insert the macro via Developer > Record Macro.
- Test with dummy data: Start with placeholder data (e.g., "ID1", "Product X") to debug formulas before using real data.
- Leverage helper columns: Add a temporary column in Sheet B to log key values before merging (e.g., "Key Collected: =B2"). This helps visualize the matching process.
Troubleshooting
-
Formula errors (#N/A or #VALUE!):
- Check that the key column in Sheet B exists in Sheet A’s data range. For example, if your formula is
=VLOOKUP(B2, SheetA!A:Z, 4, FALSE), ensure Column 4 (data column) in Sheet A includes the field you’re querying (e.g., "Product Name"). - If keys are text but formatted differently (e.g., "John" vs. "JOHN"), use
=LOWER(B2)in Sheet B’s key column before merging or adjust Sheet A’s key to match formatting. - For partial matches, use
=SEARCH(B2, SheetA!A:A)instead ofMATCH.
- Check that the key column in Sheet B exists in Sheet A’s data range. For example, if your formula is
-
Data not merging:
- Verify the key columns are aligned. For example, if Sheet A’s key is in Column A and Sheet B’s key is in Column C, adjust your formula to reference the correct range (e.g.,
=VLOOKUP(C2, SheetA!A:Z, 4, FALSE)). - Check for hidden rows or formatting differences (e.g., merged cells). Select the entire range before copying data to avoid hidden columns.
- If using Power Query, ensure the merge step isn’t blocked by mismatched data types (e.g., a key column in Sheet A is numeric while Sheet B’s is text).
- Verify the key columns are aligned. For example, if Sheet A’s key is in Column A and Sheet B’s key is in Column C, adjust your formula to reference the correct range (e.g.,
-
Slow performance:
- For large datasets (>10,000 rows), avoid VLOOKUP. Use INDEX-MATCH or Power Query, which are more efficient.
- In Excel, add an index to your formulas (e.g.,
=INDEX(SheetA!D:D, MATCH(B2, SheetA!A:A, 0), 1)) to speed up lookups. - Disable macros or reduce add-ins temporarily to rule out conflicts.
-
No matches found:
- Manually verify a few rows. A blank Sheet B means keys in Sheet A don’t exist in Sheet B’s key column. Add a helper column to log this (e.g., "Match Status: =IFERROR(...)" to show "Yes" or "No").
- For partial matches, use
=IF(ISNUMBER(MATCH(...)), "Match", "No")to flag results.
Frequently Asked Questions
How do I match data between two sheets if the keys are in different columns?
Use a helper column in Sheet B to log the key values before merging. For example, add a column labeled "Key Lookup" and use a formula like =B2 (the key from Sheet B). Then reference this helper column in your VLOOKUP or INDEX-MATCH formula instead of Sheet B’s original key column.
What if my data has duplicates in the key column?
Power Query or Google Sheets’ merge will handle duplicates automatically by keeping all occurrences. In Excel, use a formula with IFERROR to ensure only the first match is displayed (or use a helper column to list all matches). To count duplicates, use =COUNTIF(SheetA!A:A, B2) in Sheet B.
Can I merge data if the key columns have different names?
Yes, but you’ll need to rename or adjust the formulas. In Power Query, rename the columns to match in both queries. In Excel, use a helper column to map names (e.g., =IF(A2="Product ID", "KeyCol", "")) and reference that column in your formula.
How do I merge data if Sheet B has more rows than Sheet A?
Your formula or merge will return blank cells for unmatched keys. Use IFERROR in Excel or enable "Merge with Partial Matches" in Google Sheets to show partial results. For a clean output, filter Sheet B to only rows with valid keys first.
What if I need to merge columns rather than just matching rows?
Use a combination of methods: copy the key column from Sheet A to Sheet B, then merge each data column separately. For example, for "Product Name":
=IFERROR(INDEX(SheetA!D:D, MATCH(B2, SheetA!A:A, 0), 1), "")
Repeat for each data column in Sheet A.
Can I automate this process for recurring tasks?
Yes. In Excel, record a macro that runs your VLOOKUP or INDEX-MATCH logic. In Google Sheets, use scripts (via Extensions > Apps Script) to automate merges with custom functions. For Power Query, save the merged dataset as a template.