how to compare two lists in google sheets for duplicates

How to Find Duplicates in Two Lists: A Step-by-Step Guide to Comparing Spreadsheets in Google Sheets

By James Brown
AD

Ever found yourself with two lengthy lists in Google Sheets, wondering if there are any duplicates hiding within? Manually cross-referencing can be time-consuming and prone to human error. Thankfully, Google Sheets offers several tools to efficiently compare two lists and identify duplicates. Let's explore three methods to achieve this.

Before we dive in, ensure both of your lists are in separate columns (ideally A and B) and there are no blank cells in the data range you want to compare.

Using the 'Remove Duplicates' Feature

This method is simple and effective for finding and removing duplicates from one list against another. However, it won't show you what the duplicates are; it will only display the count.

AD
How Do I Find Duplicates in Two Columns in Google Sheets?
How Do I Find Duplicates in Two Columns in Google Sheets?
How to Find and Highlight Duplicates in Google Sheets [The Easiest Way]
How to Find and Highlight Duplicates in Google Sheets [The Easiest Way]
Comparison Tracker Google Sheets Spreadsheet
Comparison Tracker Google Sheets Spreadsheet

Here's how to use it:

Using the Remove Duplicates Ribbon

1. Select the range of cells containing the first list (e.g., Column A).

the google spreadsheet has been updated to help students learn how to use them
the google spreadsheet has been updated to help students learn how to use them
Free To-Do List Template: Excel & Google Sheets Spreadsheet for Tasks
Free To-Do List Template: Excel & Google Sheets Spreadsheet for Tasks
Quick tutorial: How to create dropdowns in Google Sheets (the easy way!)
Quick tutorial: How to create dropdowns in Google Sheets (the easy way!)

2. Click on 'Data' in the menu, then 'Remove duplicates'. A dialog box will appear.

3. Ensure only the column containing the first list is checked. Click 'Remove duplicates'. Google Sheets will count and remove duplicates from the second list (Column B) against the first.

AD

Using the 'Remove Duplicates' Script

If you're comfortable with scripts, you can automate this process. Here's a simple script to remove duplicates:

Master VLOOKUP with MATCH in Google Sheets
Master VLOOKUP with MATCH in Google Sheets
Remove Duplicates in Google Sheets (2 Quick and Easy Ways)
Remove Duplicates in Google Sheets (2 Quick and Easy Ways)
How to use IFNA in Google Sheets to handle errors - Sheetgo
How to use IFNA in Google Sheets to handle errors - Sheetgo
Compare and Highlight Duplicate or Unique values in #Excel
Compare and Highlight Duplicate or Unique values in #Excel
How to find duplicates in Google Sheets
How to find duplicates in Google Sheets
Create an Interactive Google Sheets Checklist: Tally Checkboxes, Use Conditional Formatting, and More
Create an Interactive Google Sheets Checklist: Tally Checkboxes, Use Conditional Formatting, and More

Code.gs:

function removeDuplicates() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var range = sheet.getRange("A2:B"); // adjust the range as needed
  range.getValues().filter(function(row){
    return !sheet.getRange("A2:A").getValues().filter(function(prevRow){
      return row[0] === prevRow[0]; // column A comparison
    }).length;
  }).forEach(function(row){
    sheet.appendRow(row); // append non-duplicates to the end of the sheet
  });
}

Adjust the range as needed, then run the script with a click. The results will be appended to the end of the sheet.

AD

Using Conditional Formatting to Highlight Duplicates

If you want to visually identify duplicates, use conditional formatting. This method allows you to color-code or highlight duplicates in the second list based on their presence in the first.

How to Combine Multiple Google Sheets Together (Tutorial)
How to Combine Multiple Google Sheets Together (Tutorial)
How To Create Checklists with Google Sheets
How To Create Checklists with Google Sheets
Google Sheets Formula Cheat Sheet
Google Sheets Formula Cheat Sheet

Here's how to set it up:

Using Custom Formula for Conditional Formatting

1. Select the range of cells containing the second list (e.g., Column B).

AD

2. Click on 'Format' in the menu, then 'Conditional formatting'.

3. Under 'Format cells if...', select 'Custom formula is'.

4. Enter the following formula: `=COUNTIF($A:$A, B1)>1` (adjust column references as needed).

5. Choose your desired formatting (e.g., fill color), then click 'Done'.

Now, any cells in Column B that contain duplicates will be highlighted according to your selected format.

Using a VLOOKUP to List Duplicates

If you want to create a new list of just the duplicates, use a VLOOKUP. This method will show you exactly which values are duplicates and in which rows they occur.

Here's how to do it:

Using VLOOKUP to List Duplicates

1. In a new column (e.g., Column C), enter the following formula: `=IF(COUNTIF($A:$A,B1)<2,, "Duplicate")`.

2. Drag this formula down to the end of your data range.

Any cells in Column B that contain duplicates will now display " Duplicate" in Column C. Adjust column references if needed.

avisualizing and managing duplicates in Google Sheets can significantly streamline your workflow and reduce manual effort. Try out these methods and watch your productivity soar!

AD