HomeGoogle DocsSpreadsheetHighlight Duplicates in Single, Multiple Columns, All Cells In Google Sheets

Highlight Duplicates in Single, Multiple Columns, All Cells In Google Sheets

Published on

How to Highlight Duplicates in Google Sheets?

The shortest answer is to count values in a column(s) as we do in running count. Then apply the fill color or text color based on the count. So for the former, we can use COUNTIF and the latter, the Format menu > Conditional formatting.

This post covers the below conditional formatting tips.

1. Formula to Highlight Duplicates in a Single Column in Google Sheets.

  • All the occurrences of the duplicate values in a single column.
  • All the occurrences, except for the first instance.

2. Formula to Highlight Duplicates in Multiple Columns in Google Sheets.

  • All the occurrences of the duplicates in two (or more) columns.
  • All the duplicates in two or more columns except for the first occurrence/instance.

The efficient way to identify duplicates in Google Sheets is by highlighting cells using the conditional formatting feature, which is built-in.

But to get the maximum output from this built-in conditional formatting feature, you should know how to use custom formulas in it.

As a side note, the best option to eliminate duplicate values is to use formulas. Google Sheets has two main functions to eliminate duplicates. You may be familiar with one of them, and that’s UNIQUE. But surprisingly, there is one more function called SORTN.

But for conditional formatting, like in Excel, we can depend on the functions COUNTIF or COUNTIFS. The use of UNIQUE or SORTN may not be handy in highlighting duplicates.

Update: Please check the new menu item Format > Remove Duplicates – How to Use Remove Duplicates Menu Command in Google Sheets.

Below you can find a few different custom formulas based on COUNTIF and COUNTIFS to highlight duplicates in Google Sheets. No doubt, each of them has its role in highlighting cells.

First, understand how to set a custom rule in conditional formatting. Then we can go to the formulas.

Must Check: Learn All Count Functions in Google Sheets.

Custom Formulas in the Conditional Formatting Panel

Before going to the formulas (rules), we should know how to use them in Google Sheets. It’s not like what we see or do in Excel. So, first, let’s go to that.

To apply custom rules (formulas for highlighting), please follow the below instructions.

1. Go to the menu Format and select Conditional formatting there.

2. It will open a sidebar panel. In that panel, here are the settings to enter the custom formula that I will provide.

how to use custom formula in conditional formatting

You can learn below the cell reference and formula to enter in the fields “Apply to range” and in the “Value or formula” field. I will explain that below.

You may choose the color you want to highlight under the formatting style (please refer to the image above).

Highlight Duplicates in a Single Column in Google Sheets

In each example, I am providing you with two formulas each. Choose the one that seems easy for you to understand.

All the Duplicates in a Column

See how to highlight values in a column automatically when it appears repeatedly. I mean more than once. I am not in favor of this sort of fill coloring.

Here the formula will highlight the first, second, third, etc., instances of any duplicate values.

highlight all the duplicates in a column

Conditional Format Rule:

Apply to Range: A2:A

Value or Formula: =countif($A$2:$A,A2)>1

Duplicates Except for the First Instance

I am usually following this method to highlight duplicates in Google Sheets. In my personal experience, this is the most preferred method among the Spreadsheet users with whom I have acquainted.

In this, I am considering the first value as a unique value. So the formula will conditionally format the value (color the cell or text) from the second instance only.

conditional format except first instances - single column

Custom Formula Rule:

Apply to Range: A2:A

Value or Formula: =countif($A$2:$A2,A2)>1

The above formula one and two are almost similar. If you carefully check, you can see a minor difference in the cell reference that is in the COUNTIF range.

This method has one advantage. To delete duplicates, you only need to select the rows containing the highlighted cells and delete them.

Unfortunately, there is no custom filter rule to filter the cells by highlighting in Google Sheets.

For that, we can use the Filter by Fill Color feature as detailed here – Filter or Sort by Font or Cell Color in Google Sheets – Built-in Feature.

Highlight Duplicates in Multiple Columns In Google Sheets

A list may contain more than two columns, or we can say arrays (ranges).

If you want to include all the columns in a list, the above formulas won’t work for you. The reason is the function in use, i.e., COUNTIF.

All the Instances of Duplicates in Multiple Columns

Here I am going to use the COUNTIFS function since multiple columns are involved. Also, this is in line with formula # 1 above. Please take a close look at the GIF capture below.

highlight duplicates in two columns

As you can see, if any of the rows entirely/completely match, then the formula highlights those rows. That means the values in both columns should match.

Custom Formula Rule:

Apply to Range: A2:B

Value or Formula: =COUNTIFS($A$2:$A, $A2:$A, $B$2:$B, $B2:$B)>1

When you have more columns, you can easily add that in this COUNTIFS formula.

Below you can find one more example to highlight duplicates in Google Sheets. Here also I include multiple columns. But the occurrence of values matters here.

Duplicates in Multiple Columns Except for the First Instance

See the formula and the live screenshot (GIF capture). This formula is in line with my single column formula # 2 above.

Apply to Range: A2:B

Value or Formula: =COUNTIFS($A$2:$A2, $A2, $B$2:$B2, $B2)>1

conditional format duplicates except first instances in two columns

Conditional Format Duplicates Across the Cells in Google Sheets

The formula will apply color to any value/cell that has repetition in any cell. I don’t usually follow this sort of rule to highlight duplicates in Google Sheets. But some of you may want such a type of conditional format rule.

This conditional formatting applies to an entire range.

highlight duplicates in Google Sheets in all cells

Apply to Range: A2:G

Value or Formula: =COUNTIF($A$2:G,Indirect(Address(Row(),Column(),)))>1

In this formula, the criterion is replaced by the INDIRECTADDRESS, ROW, and COLUMN combination formula.

The COUNTIF syntax for Reference: COUNTIF(range, criterion)

The combination formula used as the criterion covers all the cells in the sheet individually in the custom formula rule.

Sample Sheet

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

SORT and SORTBY – Excel Vs Google Sheets

While Excel offers the SORT and SORTBY functions for sorting a table, Google Sheets...

Get Top N Values Using Excel’s FILTER Function

When using the FILTER function in Excel to extract the top N values, it's...

XLOOKUP in Excel: Working with Visible Rows in a Table

In Excel, the XLOOKUP function isn't inherently designed to exclusively work with visible rows;...

SUMPRODUCT Differences: Excel vs. Google Sheets

The core purpose of the SUMPRODUCT function remains consistent across both Excel and Google...

More like this

Interactive Random Task Assigner in Google Sheets

You have multiple tasks and multiple people. Here's a fun way to randomly assign...

Google Sheets Bar and Column Chart with Target Coloring

To color each data point in the column or bar chart according to the...

Analyzing Column A Between Non-Adjacent Values in Column B: Google Sheets

This tutorial addresses a common scenario encountered in Google Sheets: how to sum, average,...

7 COMMENTS

  1. Hi Prashanth,

    The last formula is nearly perfect for what I want to do but I’m wondering if it is possible to modify it?

    This is the formula I’m talking about:

    =COUNTIF($A$2:G, INDIRECT(ADDRESS(ROW(),COLUMN(),)))>1

    I want to limit it to looking at 4 rows and 4 columns at a time …but on multiple sets of data on the one worksheet. i.e. I have 40 sets of data that are 4 rows each and I want to highlight duplicates within each set.

    Ideally, the conditional formatting rules would continue to work as I copy/paste the last set onto empty rows at the bottom of the worksheet (as a template for the next set). I’ve currently achieved this with about 20 separate formatting rules that are simply =E7=C4 but it’s messy.

    The current formula is looking at the entire worksheet.

    Happy to share my google sheet with you.

  2. Hi! I’m trying to use this formula from your post =COUNTIFS($A$2:$A2, $A2, $B$2:$B2, $B2)>1 to highlight duplicates in my columns but it’s not really working…

    I have multiple columns, is there a limit?

    Eg. I have 6 classes (this ranges to a long column line) and per class, there are 2-time slots and 6 teachers (which is indicated by a drop-down).. so I’m trying to make it highlight if someone schedules the same teacher on the same timeslot in different classes…

    • I forgot to indicate that it’s not working when I included all the column range needed. It seems to only work if there is value in all the range. I don’t know how to make it highlight “when” the duplicates occur not when it’s all filled up.. sorry if I’m not making any sense.

      • Hi, Kim,

        You can explain the scenario with the help of a demo sheet. Show me the data. Also, please don’t forget to manually highlight the required results.
        Let me try then.

        Best,

  3. I am very much interested in knowing tricky formulas using google sheet. And your site very helpful as per my requirement. Thanx a lot

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.