How to compare two columns and remove duplicates
Tutor 5 (87 Reviews)
Excel Tutor
Still stuck with a Excel question
Ask this expertAnswer
To compare two columns and remove duplicates in Excel, follow these steps carefully. This process ensures data integrity while eliminating repeated entries across the columns.
Step 1: Identify Duplicates Using Conditional Formatting
Select the first column you want to compare.
Go to Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values.
Choose a formatting style to highlight duplicates.
Repeat the same for the second column.
This highlights any duplicate entries between the columns for visual inspection.
Step 2: Use the COUNTIF Formula to Compare Two Columns
A more precise method uses formulas to identify duplicates. Suppose your data is in Column A and Column B, starting from row 2.
In Column C, enter the formula:
Drag the formula down to check all rows in Column A.
"Duplicate" indicates values in Column A that exist in Column B.
Reverse the columns to check Column B against Column A using:
This method works for exact matches and can handle large datasets efficiently.
Step 3: Remove Duplicates Automatically
Select the entire dataset or the column where duplicates exist.
Go to Data > Remove Duplicates.
Check the column(s) to scan for duplicates.
Click OK. Excel will remove duplicates and show the number of removed entries.
For multi-column comparison:
Select all relevant columns.
In Remove Duplicates, ensure all columns are checked.
Excel will remove rows where all selected column values match exactly.
Step 4: Use a Formula to Extract Unique Values
To extract unique values into a new column, use the UNIQUE function (Excel 365 and newer):
This formula outputs all distinct values from the selected range, excluding duplicates automatically.
Step 5: Tips for Large Datasets
Convert your data to an Excel Table using Ctrl + T. Tables automatically adjust formulas and ranges when new data is added.
Use Power Query for advanced comparison and deduplication:
Go to Data > Get & Transform Data > From Table/Range.
Use Merge Queries to compare columns and filter duplicates.
Load the cleaned data back to the worksheet.
Step 6: Handling Case Sensitivity
Excel formulas like COUNTIF are not case-sensitive. For case-sensitive comparison, use:
This identifies duplicates only when the text case matches exactly.
Step 7: Examples
Column A:
Column B:
Using the COUNTIF method, results in Column C:
| A | C |
|---|---|
| Apple | Duplicate |
| Banana | Duplicate |
| Orange | Unique |
| Mango | Unique |
Removing duplicates from Column A results in only Orange and Mango remaining.
This approach ensures duplicates are identified accurately and removed efficiently without manual inspection, even for large datasets.
Get Online Tutoring or Questions answered by Experts.
You can post a question for a tutor or set up a tutoring session
Answers · 1
What is the formula to highlight duplicate values
Answers · 1
What is the formula to remove duplicates
Answers · 1
How to delete duplicate values in excel
Answers · 1
How to delete duplicate rows based on one column
Answers · 1