Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Find Duplicates in Two Excel Workbooks: Easy Methods

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To find duplicates between two different Excel workbooks, the most reliable method is to consolidate the data into a single workbook and use the Conditional Formatting tool or the VLOOKUP function. Because Excel's built-in duplicate highlighter only works within a single sheet, you must bring the data together or reference one sheet from another to identify overlapping records.

What You'll Need

  • Two separate Excel workbooks (.xlsx or .csv files) containing the data you wish to compare.
  • A common unique identifier in both files (such as an Email Address, Product ID, or Social Security Number) to ensure accuracy.
  • Microsoft Excel installed on your desktop (Windows or macOS).

Step-by-Step

Depending on your comfort level with Excel, you can use a visual method (Conditional Formatting) or a data-driven method (VLOOKUP). Note that menu labels may differ slightly depending on your version of Excel, your operating system, or your regional settings.

Method 1: Using Conditional Formatting (Visual Method)

  1. Open both workbooks. Launch the two files you want to compare.
  2. Consolidate the data. Create a new, third workbook. Copy the column containing the unique identifiers from Workbook A and paste it into Column A of the new workbook. Then, copy the corresponding column from Workbook B and paste it directly underneath the first list in Column A.
  3. Select the data range. Click and drag to highlight all the cells in Column A that contain your data.
  4. Apply Highlighting. Go to the Home tab on the top ribbon. In the Styles group, click Conditional Formatting > Highlight Cells Rules > Duplicate Values....
  5. Choose your format. In the dialog box that appears, ensure the first dropdown is set to "Duplicate." In the second dropdown, select a fill color (e.g., "Light Red Fill with Dark Red Text"). Click OK.
  6. Analyze results. Every cell that is highlighted in red exists in both of your original workbooks.

Method 2: Using VLOOKUP (Data Method)

This method is better for large datasets because it allows you to keep your original workbooks separate and creates a clear "Yes/No" indicator for duplicates.

  1. Open both workbooks. Ensure Workbook A (your primary list) and Workbook B (the list you are checking against) are both open.
  2. Create a helper column. In Workbook A, click on the first empty cell to the right of your data (for example, cell B2). Label this column "Duplicate Check."
  3. Enter the VLOOKUP formula. Type the following formula into cell B2: =VLOOKUP(A2, '[WorkbookB.xlsx]Sheet1'!$A:$A, 1, FALSE).
    • A2 is the value in Workbook A you are looking for.
    • '[WorkbookB.xlsx]Sheet1'!$A:$A is the reference to the column in the second workbook. When typing this, you can simply click over to Workbook B and select the column with your mouse.
    • 1 tells Excel to return the value from the first column of the range.
    • FALSE ensures Excel looks for an exact match only.
  4. Apply to all rows. Hover your mouse over the bottom-right corner of cell B2 until you see a small black cross (the fill handle). Double-click the cross to drag the formula down to the bottom of your list.
  5. Interpret the results. If the value appears in the cell, it is a duplicate. If the cell displays #N/A, the value is unique to Workbook A and does not exist in Workbook B.
  6. Clean up the view (Optional). To make it easier to read, you can wrap the formula in an IFERROR function: =IFERROR(IF(VLOOKUP(A2, '[WorkbookB.xlsx]Sheet1'!$A:$A, 1, FALSE), "Duplicate", ""), "Unique"). This will replace the #N/A errors with the word "Unique."

Common Mistakes

  • Ignoring Leading or Trailing Spaces: This is the most common reason why duplicates aren't found. If Workbook A has "John Doe" and Workbook B has "John Doe " (with a space at the end), Excel will treat them as different values.
  • Mismatched Data Types: If one workbook stores IDs as "Numbers" and the other stores them as "Text," VLOOKUP and Conditional Formatting will not recognize them as duplicates, even if the digits are identical.
  • Comparing Non-Unique Columns: Trying to find duplicates based on "First Name" alone will result in many false positives (e.g., every "Michael" will be flagged). Always use a unique identifier like an email or ID number.
  • Incorrect Range Locking: When using formulas, forgetting to use absolute references (the $ signs in $A:$A) can cause the lookup range to shift as you drag the formula down, leading to missed duplicates.

Tips

  • Use the TRIM function: To fix the space issue mentioned above, create a temporary column and use =TRIM(A2). This removes all leading and trailing spaces, ensuring a clean comparison.
  • Convert to Tables: Press Ctrl + T to turn your data ranges into official Excel Tables. This makes your formulas dynamic, meaning if you add new rows to your workbooks, the duplicate check will update automatically.
  • Use a Pivot Table for Summary: If you have consolidated your data into one sheet, insert a Pivot Table. Put your unique identifier in both the "Rows" area and the "Values" area. Any item with a count greater than 1 is a duplicate.
  • Sort your data: Sorting both columns alphabetically before comparing can help you manually spot-check a few entries to ensure the formulas are working as intended.

Troubleshooting

If your results seem incorrect or the formulas aren't working, try these steps in order:

  1. Check for Hidden Characters: Sometimes data imported from the web contains non-breaking spaces. Use the =CLEAN() function to remove non-printable characters.
  2. Verify Data Types: Select the column in both workbooks, go to the Home tab, and change the format dropdown to "Text." If the values don't change alignment, you may need to use the "Text to Columns" feature (under the Data tab) to force the entire column into a consistent format.
  3. Check Workbook Links: If you used the VLOOKUP method and then closed Workbook B, you might see a security warning about "Updating Links." Click "Enable Content" to allow Workbook A to communicate with the closed file.
  4. Refresh Conditional Formatting: If you added new data to a consolidated list and the colors didn't update, go to Conditional Formatting > Manage Rules and ensure the "Applies to" range covers all your new rows.

Frequently Asked Questions

Can I find duplicates without moving data to one sheet?

Yes, by using the VLOOKUP or XLOOKUP function. These formulas allow you to reference a range in a completely different workbook, meaning your original files remain untouched.

Will this work for thousands of rows?

Yes, but Conditional Formatting can slow down your computer if you have tens of thousands of rows. For very large datasets, the VLOOKUP method or using Power Query is significantly faster and more stable.

How do I delete the duplicates once I find them?

Once you have highlighted duplicates or marked them with a formula, use the Filter tool (Data > Filter). Filter for the "Duplicate" label or the specific fill color, select all the filtered rows, right-click, and choose Delete Row.

What is the difference between VLOOKUP and XLOOKUP for this task?

XLOOKUP is a newer version available in Microsoft 365. It is easier to use because it doesn't require you to count column index numbers and defaults to an exact match, reducing the chance of errors.

Can I find duplicates based on two columns (e.g., First and Last Name)?

The easiest way is to create a "Helper Column" in both workbooks. Use the formula =A2&B2 to combine the first and last names into one string, then run the duplicate check on that combined column.