Smart Systems for Home

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

Compare Two Columns in Excel for Duplicates: 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

Comparing two columns in Excel for duplicates allows you to quickly identify overlapping data, find missing entries, or ensure that two lists are synchronized. The fastest way to achieve this is by using Conditional Formatting to highlight duplicates or the VLOOKUP/XLOOKUP function to create a side-by-side comparison list. These methods work across all modern versions of Excel, though menu labels may differ slightly depending on whether you are using Windows, macOS, or Excel for the Web.

What You'll Need

  • Microsoft Excel installed on your computer or access to the web-based version.
  • A spreadsheet containing at least two columns of data that you wish to compare.
  • Consistent data formatting (e.g., ensuring both columns are formatted as Text or both as Numbers) to avoid false negatives.

Step-by-Step

Depending on your goal—whether you want to visually highlight duplicates or create a separate list of matches—choose one of the following three methods.

Method 1: Using Conditional Formatting (Visual Identification)

This is the best method if you want to see exactly where the duplicates are located within your existing layout without adding new formulas.

  1. Open your Excel workbook and select the data in both columns. To do this, click and drag your mouse across the first column, hold the Ctrl key (Cmd on Mac), and then click and drag across the second column.
  2. Navigate to the Home tab on the top ribbon.
  3. In the Styles group, click on Conditional Formatting.
  4. Hover over Highlight Cells Rules and select Duplicate Values... from the side menu.
  5. A dialog box will appear. In the first dropdown menu, ensure Duplicate is selected. In the second dropdown, choose your preferred highlight color (e.g., Light Red Fill with Dark Red Text).
  6. Click OK. All cells that appear in both columns will now be highlighted.

Method 2: Using the VLOOKUP Function (Detailed Mapping)

Use this method if you need a third column to explicitly state "Match" or "No Match" for every row in your first list.

  1. Assuming your first list is in Column A and your second list is in Column B, click on cell C2 (the first empty cell next to your data).
  2. Type the following formula: =IF(ISNA(VLOOKUP(A2, B:B, 1, FALSE)), "No Match", "Match").
  3. Press Enter. This formula tells Excel to look for the value of A2 within the entirety of Column B. If it cannot find it (resulting in an #N/A error), it returns "No Match"; otherwise, it returns "Match".
  4. To apply this to the rest of your list, click the small green square (fill handle) at the bottom-right corner of cell C2 and drag it down to the end of your data set.

Method 3: Using the XLOOKUP Function (Modern Excel)

XLOOKUP is a more powerful and intuitive version of VLOOKUP available in Microsoft 365 and Excel 2021 or later.

  1. Click on cell C2.
  2. Enter the formula: =XLOOKUP(A2, B:B, B:B, "Not Found").
  3. Press Enter. If the value in A2 exists in Column B, XLOOKUP will return the value itself. If it does not exist, it will display "Not Found".
  4. Drag the fill handle down to complete the column.

Common Mistakes

Even experienced users often run into issues when comparing columns due to the way Excel interprets data. Be mindful of the following common errors:

  • Trailing Spaces: This is the most frequent cause of "false negatives." If one cell contains "Apple" and the other contains "Apple " (with a space at the end), Excel treats them as completely different values. To fix this, you can use the =TRIM() function to remove extra spaces from your data before comparing.
  • Data Type Mismatch: Excel distinguishes between numbers and text. If Column A contains the number 123 (formatted as a Number) and Column B contains 123 (formatted as Text), the comparison will fail. Ensure both columns have the same data format via the Home > Number dropdown.
  • Case Sensitivity: By default, standard Excel functions like VLOOKUP and Conditional Formatting are not case-sensitive. "APPLE" and "apple" will be flagged as duplicates. If you need a case-sensitive comparison, you must use a combination of the EXACT function and FILTER or MATCH.
  • Incorrect Range Selection: When using Conditional Formatting, users often forget to select both columns. If you only select one, Excel will only find duplicates within that single column, rather than comparing it to the second one.

Tips

To make your data comparison more efficient, consider these professional workflows:

  • Use Excel Tables: Convert your data ranges into Tables (Ctrl + T). When you add a formula to a Table column, Excel automatically fills the formula down to the bottom of the list, saving you from manual dragging.
  • Filter by Color: After using Conditional Formatting to highlight duplicates, you can quickly isolate them. Click the filter arrow in the column header, select Filter by Color, and choose the highlight color you used. This hides all unique values and shows only the duplicates.
  • Remove Duplicates: If your goal is to clean the data rather than just find matches, use the Data > Remove Duplicates tool. This will permanently delete duplicate entries from your selection.
  • Sorting First: While not required for formulas, sorting both columns alphabetically (A-Z) makes it much easier for a human to spot-check the results of a formula or highlight.

Troubleshooting

If your comparison is not returning the expected results, follow these steps in order of complexity:

  1. Check for Hidden Characters: If two cells look identical but aren't matching, click into the cell and check for leading or trailing spaces. Use =LEN(cell) on both cells; if the character counts differ, there is a hidden space or character.
  2. Force Format Conversion: Select the column, go to the Data tab, select Text to Columns, and simply click Finish. This often forces Excel to re-evaluate the data type of the cells and can fix number-as-text errors.
  3. Verify Absolute References: If you are using a formula like =VLOOKUP(A2, B2:B100, 1, FALSE) and dragging it down, the range B2:B100 will shift to B3:B101, B4:B102, and so on. Use absolute references ($B$2:$B$100) or select the entire column (B:B) to keep the lookup range static.
  4. Clear Existing Formatting: If Conditional Formatting isn't appearing, you may have conflicting rules. Go to Conditional Formatting > Clear Rules > Clear Rules from Entire Sheet and try again.

Frequently Asked Questions

Can I compare two columns on different sheets?

Yes. When selecting the range for VLOOKUP or XLOOKUP, simply click over to the other sheet and select the column. The formula will look like =VLOOKUP(A2, Sheet2!B:B, 1, FALSE).

How do I find values that are in Column A but NOT in Column B?

Use the VLOOKUP method described above. Any row that returns "No Match" represents a value present in Column A that is missing from Column B.

Is there a way to compare columns without using formulas?

Yes, the Conditional Formatting method is entirely formula-free. Additionally, you can copy both columns into one single column and use the Remove Duplicates tool to see what remains.

Does this work for very large datasets (100,000+ rows)?

Yes, though VLOOKUP can slow down your workbook with massive datasets. For very large files, XLOOKUP is generally more efficient, or you can use the Power Query tool (Data > Get Data) to perform a "Merge Queries" operation, which is designed for big data.

Can I highlight only the unique values instead of duplicates?

Yes. In the Conditional Formatting Duplicate Values dialog box, change the first dropdown from "Duplicate" to "Unique". This will highlight every cell that does not have a match in the other column.