Conditional Formatting Duplicates Across Tabs in Google Sheets

Published on

To conditional format duplicates across sheet tabs in Google Sheets, you can use two functions: COUNTIF and INDIRECT. Optionally, you can also use VSTACK and TOCOL.

In conditional formatting rules, when referring to a cell or cell range in a different sheet tab, you must use the INDIRECT function. For example, you can’t use Sheet2!A1 from “Sheet1” in a conditional format rule; instead, use it as INDIRECT("Sheet2!A1").

The purpose of COUNTIF is to conditionally count values in a range, which is useful for identifying duplicates. Highlighting the cells where COUNTIF returns a value > 1 is the logic for highlighting duplicates in Google Sheets.

VSTACK combines ranges, which can also be done with array constants, and TOCOL removes blank cells in the combined range.

Highlighting Duplicates Across Sheet Tabs in a Single Column

I am using only two sheet tabs in my example. Please follow my example carefully, and it will help you extend the formulas to more sheets.

Here is the content in column A of Sheet1:

Sheet1:

Duplicates Across Sheets - Data in Sheet1

See what happens in Sheet2 when I enter duplicates of Sheet1 column A values.

Sheet2:

Example of Highlighting Duplicates Across Sheets

Go back to Sheet1 and see that the duplicates are highlighted there too.

The formula to conditionally format duplicates across sheet tabs in a single column:

For Sheet1:

=COUNTIF(TOCOL(
   VSTACK(
      $A$2:$A, 
      INDIRECT("Sheet2!A2:A")
   ), 3), A2)>1

For Sheet2:

=COUNTIF(TOCOL(
   VSTACK(
      $A$2:$A, 
      INDIRECT("Sheet1!A2:A")
   ), 3), A2)>1

Formula Explanation:

The VSTACK function vertically stacks the ranges in two sheets, and the TOCOL function removes empty cells and error values to improve performance.

The COUNTIF function counts the value in cell A2 in the current sheet within this combined range. If the count is greater than 1, the sheet highlights it.

Applying the Custom Rules in Both Sheets

The conditional formatting option is available under the Format menu in Google Sheets.

Steps to Conditional Format Duplicates Across Two Sheets:

Inputting the Across-Sheet Formula in the Conditional Formatting Panel
  1. Select the range A2:A in Sheet1 (from A2 to the last row you want in that column).
  2. Open the conditional format rule from the menu: Format > Conditional formatting.
  3. Under “Format cells if,” select “Custom formula is.”
  4. Copy-paste the above first formula in the given field.
  5. Select the formatting style and click Done.

In Sheet2, follow the same instructions, but use the Sheet2 formula provided above.

Once applied, you will notice that if a value repeats in either sheet (Sheet1 or Sheet2), it gets highlighted in the relevant sheet or both.

That’s how we highlight duplicates across sheet tabs in one column.

How to Add a Third Sheet for Highlighting

If you want to conditional format across three sheet tabs, you should use the following formulas.

Within VSTACK, which vertically stacks the range to highlight from all sheets, specify the third sheet name. The current sheet reference can be specified directly without INDIRECT or the sheet name.

  • Formula for Sheet1:
=COUNTIF(TOCOL(
   VSTACK(
      $A$2:$A, 
      INDIRECT("Sheet2!A2:A"), 
      INDIRECT("Sheet3!A2:A")
   ), 3), A2)>1
  • Formula for Sheet2:
=COUNTIF(TOCOL(
   VSTACK(
      $A$2:$A, 
      INDIRECT("Sheet1!A2:A"), 
      INDIRECT("Sheet3!A2:A")
   ), 3), A2)>1
  • Formula for Sheet3:
=COUNTIF(TOCOL(
   VSTACK(
      $A$2:$A, 
      INDIRECT("Sheet1!A2:A"), 
      INDIRECT("Sheet2!A2:A")
   ), 3), A2)>1

Highlighting Duplicates Across Sheet Tabs in Multiple Columns

In the above examples, we used custom rules in conditional formatting to highlight duplicates in one column across all sheets.

If you want to highlight multiple columns across sheets, make these changes in the formulas:

For example, for three columns:

  1. $A$2:$A will become $A$2:$C
  2. A2:A within INDIRECT will become A2:C
  3. Within the Conditional Formatting panel, the “Apply to range” must be set to A2:C.

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 Data but Keep Blank Rows in Excel and Google Sheets

Using a dynamic array formula or the FILTER command, we can sort data and...

Lookup Values Under Categories in Excel and Google Sheets

We can use a combination of XLOOKUP and VLOOKUP in both Excel and Google...

Extract Items Under a Category from the Same Column in Excel

In Excel, you can use a combination of the XLOOKUP and DROP functions to...

How to Create a Searchable Table in Excel Using the FILTER Function

Finding specific records, or rows containing the required information, is straightforward in Excel using...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

20 COMMENTS

  1. Hello! It has been helpful! I am wondering how I would do this:

    Sheet 2 column A has IDs.
    Sheet 1 column A has IDs, and column B has a “Yes” or “No” answer.

    I want to highlight Sheet 2, column A if column B in Sheet 1 (with the matching ID number) = “Yes.”

    I do hope that made sense and that you can help!

    Thank you!

  2. Can we highlight duplicates in multiple sheets within a workbook in google sheets?

    Can you write the syntax for 6 sheets?

    • Hi, Divya,

      I don’t recommend highlighting duplicates across several sheets as it can affect performance.
      In that case, I would recommend importing data to a single sheet and then highlight it.

      Query Syntax/formula to Import cell range A2:A in three sheets to the fourth sheet in that workbook:

      =Query({Sheet1!A2:A;Sheet2!A2:A;Sheet3!A2:A},
      "Select * where Col1 is not null")

      If you are still interested in highlighting across six sheets, here is the syntax that you can follow.

      For two sheets, I have already explained. Here is when three sheets are involved.

      Format “Apply to range” is A2:A in all three sheets (tabs).

      Sheet 1:

      =(countif($A$2:$A,A2)+countif(indirect("Sheet2!$A$2:$A"),A2)+
      countif(indirect("Sheet3!$A$2:$A"),A2))>1

      Sheet2:

      =(countif($A$2:$A,A2)+countif(indirect("Sheet1!$A$2:$A"),A2)+
      countif(indirect("Sheet3!$A$2:$A"),A2))>1

      Sheet 3:

      =(countif($A$2:$A,A2)+countif(indirect("Sheet1!$A$2:$A"),A2)+
      countif(indirect("Sheet2!$A$2:$A"),A2))>1

      You can follow this pattern to include more sheets in the conditional format rule.

  3. Hi Prashanth,

    Great resource, I keep coming back but slowly getting it. Sorry, I’m new to spreadsheets.

    Can you show me a formula to remove duplicates across a multiple 7 to 31 across tabs in Google sheet (each day in month list)?

    I’ve seen the 2 videos, and it didn’t work for me sorry 🙁

    I’d like to check 7 days period.

  4. This is just what I’m looking for, though what would the formula be for Sheet 2 if I do not want to highlight duplicates that are within Sheet 2?

    If I list Avacaods twice within Sheet 2 they are both highlighted as duplicates (Avacados are not listed in Sheet 1).

    I only want to highlight duplicates comparing to Sheet 1.

  5. Thanks for this solution!

    For Sheet1:

    =(countif($A$2:$A,A2)+countif(indirect("Sheet2!$A$2:$A"),A2))>1

    For Sheet2:

    =(countif($A$2:$A,A2)+countif(indirect("Sheet1!$A$2:$A"),A2))>1

    How can we add the same formula if we have sheet 3, sheet 4, sheet x …

    Thank you!

  6. This is very helpful. I need to check if a value in a cell exists in a column in another worksheet. How to make this formula work in that situation?

    Thanks!

    • Hi, Donna,

      You may use the MATCH function.

      To match the value in cell B4 (“Sheet1”) in another sheet (column C in “Sheet2”) use the below formula in cell C4 in “Sheet1”.

      =ifna(match(B4,Sheet2!C:C)>0,FALSE)

      It would return TRUE for match and FALSE for a mismatch.

  7. Hi, whoa I can never figure these things out myself! I was wondering if you could help me – I have two lists of customers

    A: All customers (including refunds)
    B: All refunds.

    So what I’m trying to do …. is produce a sheet that ONLY shows customers who did not get a refund. Using your strategy above works….except now the rows are highlighted for me to see but I can’t bulk delete them…

    Is there a way to do something like…
    IF THERE ARE DUPLICATES, DELETE BOTH?

    I can upload both lists on the same sheet, it doesn’t have to be separate sheets so I think that will make it easier?

    But everything I’ve looked online only shows me how to delete duplicates. What I’m trying to do is actually DELETE both when duplicates are found.

    any insight you can provide, I would really appreciate!

    • Hi, janine,

      If you use conditional formatting, now you can bulk delete the highlighted cells. I hope you are aware of the new feature in Sheets – Filter or Sort by Font or Cell Color in Google Sheets.

      If you are looking to filter the customers who didn’t get a refund, then try this filter.

      A1:A – All customers (including refunds)
      B1:B – All refunds.

      Assume the first row (A1:B1) contains headers.

      The formula to be used in cell C2 (case insensitive):

      =filter(A2:A,countif(B2:B,A2:A)=0)

      Case sensitive formula:

      =filter(A2:A,regexmatch(A2:A,"^"&textjoin("$|^",true,B2:B)&"$")=FALSE)

  8. This is so useful! Thank you so much!

    Would you be able to suggest a solution where this also works if cells in some of the columns are empty? As it stands today, the above does not highlight rows that have blank cells (even if they are identical).

    As an example use case, when importing bank statements from a “new” sheet to an “existing” sheet, we want to highlight duplicate rows, but for two of the columns (debit and credit), there are values only in one of those columns.

    Example data:
    Date, Description, Debit, Credit
    ====================
    01/01, Target, $10, <>
    01/01, BestBuy returns,<>, $50
    02/01, Target, $20, <>

    Your help would be much appreciated. Thank you once again.

  9. Hi,

    can I use match function across two tabs? I used COUNTIF, but the problem is that it highlights not only the duplicates between the tabs but also duplicates in one tab.

    Best,
    Sebastian

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.