Niche Capital

How to Find, Highlight, and Remove Duplicates in Google Sheets

img legovl9m9jz2s1zpluvr4y8j

Share This Post

How to Find, Highlight, and Remove Duplicates in Google Sheets

Table of Contents

Introduction

Managing data effectively is crucial for businesses, students, and anyone dealing with large datasets. One common issue is dealing with duplicate entries. Google Sheets provides various tools and techniques to identify, highlight, and remove these duplicates, ensuring your data remains clean and accurate. This guide will walk you through each step, providing best practices and tips to handle duplicates efficiently.

Finding Duplicates in Google Sheets

Identifying duplicates is the first and essential step in data management. Google Sheets offers several methods to find duplicates, depending on the complexity and size of your dataset.

Using Conditional Formatting

Conditional Formatting is a simple and effective way to find duplicates. Here’s how you can use it:

  1. Select the Range: Highlight the range of cells you want to check for duplicates.
  2. Open Conditional Formatting: Go to Format > Conditional formatting.
  3. Apply the Rule: In the Format cells if dropdown, select Custom formula is and enter the formula =countif(A:A, A1)>1 (replace A:A and A1 with the appropriate range).
  4. Choose the Formatting Style: Select a formatting style (such as a fill color) that will make the duplicates stand out.
  5. Apply the Rule: Click Done. Duplicates will now be highlighted.

Using Functions

For more control, you can use Google Sheets functions like COUNTIF and UNIQUE:

  1. Create a Helper Column: Insert a new column next to your data.
  2. Enter the Formula: In the first cell of the helper column, enter =COUNTIF(A:A, A1) (adjust the range as needed).
  3. Copy the Formula: Drag the fill handle down to apply the formula to the entire column. Any cell with a value greater than 1 indicates a duplicate.

Highlighting Duplicates in Google Sheets

Highlighting duplicates helps in quickly spotting them. In addition to Conditional Formatting, here are some advanced techniques for highlighting duplicates.

Using Apps Script

Google Apps Script allows automating the highlighting process:

  1. Open Script Editor: Go to Extensions > Apps Script.
  2. Enter the Script: Copy and paste the following script:

\`javascript
function highlightDuplicates() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = sheet.getDataRange().getValues();
var colors = [];
for (var i = 0; i < data.length; i++) { colors[i] = []; for (var j = 0; j < data[i].length; j++) { colors[i][j] = (data[i][j] && countOccurrences(data, data[i][j]) > 1) ? ‘#FFDDC1’ : null;
}
}
sheet.getRange(1, 1, data.length, data[0].length).setBackgrounds(colors);
}

function countOccurrences(array, value) {
var count = 0;
for (var i = 0; i < array.length; i++) {
for (var j = 0; j < array[i].length; j++) {
if (array[i][j] === value) {
count++;
}
}
}
return count;
}
\

  1. Save and Run: Save the script and run it. Duplicates will be highlighted.

Removing Duplicates in Google Sheets

After identifying and highlighting duplicates, the next step is to remove them. Google Sheets provides both manual and automated ways to remove duplicates.

Using the Built-in Tool

  1. Select the Range: Highlight the range containing duplicates.
  2. Remove Duplicates: Go to Data > Data cleanup > Remove duplicates.
  3. Configure the Settings: In the Remove duplicates dialog, choose which columns to check for duplicates.
  4. Remove Duplicates: Click Remove duplicates. The duplicates will be deleted, and a summary dialog will display the number of duplicates removed.

Using a Formula-Based Approach

You can use formulas to filter out duplicates:

  1. Create a New Sheet: Insert a new sheet for filtered data.
  2. Enter the Formula: Use the UNIQUE function to list unique entries. For example, =UNIQUE(Sheet1!A:A) will list only unique values from column A of Sheet1.

Advanced Tips for Handling Duplicates

Handling duplicates can be straightforward, but optimizing the process can save time and ensure better data integrity. Here are some advanced tips:

Combining Multiple Methods

Using a combination of the methods discussed can identify and manage duplicates more effectively. For example, use Conditional Formatting to highlight, a helper column to identify, and Apps Script for automation.

Automating with Macros

Macros can automate repetitive tasks. Record a macro to highlight and remove duplicates, and assign it a shortcut for quick execution.

Analyzing Patterns

Analyze the patterns in your data to understand why duplicates occur. This can help in preventing future duplicates by addressing the root causes.

Using Add-ons

Explore add-ons like Remove Duplicates by Ablebits to enhance the built-in capabilities of Google Sheets.

Conclusion

Managing duplicates in Google Sheets is essential for maintaining clean and accurate data. From simple methods like Conditional Formatting to advanced techniques using Apps Script and macros, Google Sheets provides a powerful set of tools to handle duplicates effectively. By following this guide, you can ensure your datasets remain tidy, improving data integrity and making your data analysis tasks more efficient and reliable.

Check out our previous blog post: Video Workflow: A Step-by-Step Guide for Beginners

Check out our next blog post: What Is Revenue? A Quick Refresher Guide

If your business is in need of capital make sure you check out what we can offer!

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

Do You Want To Grow your Business?

6 About Creative Digital Agency Hero