Finding Duplicate Data Across Worksheets

Written by Allen Wyatt (last updated August 24, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


2

Tzvi has a workbook that has multiple worksheets containing names and addresses. He can use conditional formatting to highlight duplicate data on a single worksheet. He wonders, though, if there is a way to highlight duplicate data appearing on multiple worksheets. For instance, if a customer name appears on the first worksheet and on the fourth worksheet in the workbook, is there a way to highlight them?

There are a couple of ways you can approach this issue. One way, of course, is to simply merge the data from your worksheets into a single worksheet, and then use conditional formatting to highlight duplicates on that one worksheet, as you are already know how to do.

If you don't want to merge the worksheet data, then you could use conditional formatting, but it would take a bit of time. First, let's make some assumptions—your data is contained in Sheet1, Sheet2, Sheet3, and Sheet4. The customer names are in a single column (column A).

The first step is to display each worksheet, in turn, select the cells in column A, and then set a conditional formatting rule that highlights duplicates. This takes care of any duplicates that may exist on the worksheets themselves.

Next, go to Sheet1, select the cells in column A, and define a new conditional formatting rule that uses a formula to determine which cells to format. Here is the formula that should be in the rule:

=COUNTIF(Sheet2!$A:$A,A1)+COUNTIF(Sheet3!$A:$A,A1)+COUNTIF(Sheet4!$A:$A,A1) > 0

This rule checks the contents of column A in Sheet1 against those in the other three worksheets. You then need to set up a similar rule in the other worksheets, making sure that the formula refers to the other worksheets in the workbook.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7837) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Changing How Word Presents Your Document

Tired of the old black-on-white text displayed by Word? Depending on your program version, you can configure Word to show ...

Discover More

Changes in Font Size when Copying

Have you ever copied information from one worksheet to another, only to have the information you paste not look the way ...

Discover More

Highlighting Every Thousandth Character

Not satisfied with the detail provided by the Word Count feature in Word? Perhaps you want to actually know where every ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Converting Conditional Formatting to Regular Formatting

Conditional formatting allows you to change how information is displayed based on rules you define. What if you want to ...

Discover More

Detecting Errors in Conditional Formatting Formulas

If an error exists in a formula tucked inside a conditional format, you may never know it is there. There are ways to ...

Discover More

Working with Multiple Conditions

When you apply conditional formatting, you are not limited to using a single condition. Indeed, you can set up multiple ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 4 + 6?

2024-08-25 10:46:41

J. Woolley

COUNTIF does not support a 3D range reference like
    Sheet1:Sheet4!$A:$A
but My Excel Toolbox includes the following function:
    COUNTIF3D(FirstSheetRange, Criteria, [LastSheetRange])
Therefore, the Tip's formula can be replaced by this formula:
    =(COUNTIF3D(Sheet1!$A:$A,A1,Sheet4!$A:$A)-COUNTIF($A:$A,A1))>0
Notice the same formula can be applied to each worksheet's conditional format because it accounts for that sheet's duplicates. In fact, the separate conditional formatting rule that highlights duplicates on a sheet can be deleted if the following formula is used for each worksheet instead:
    =COUNTIF3D(Sheet1!$A:$A,A1,Sheet4!$A:$A)>1
A worksheet’s name must be surrounded by apostrophes if it includes a space or other special character.
To edit a rule's formula in the Conditional Formatting Rules Manager, first click Edit Rule..., then click within the formula and press F2 to enable cursor movement using the arrow keys, Home, End, etc.
For more on 3D range references, see https://excelribbon.tips.net/T011803
And see https://sites.google.com/view/MyExcelToolbox/


2024-08-24 08:36:41

Ron S

You can use PowerQuery to merge the tabs into a single tab, In PQ you can add a new column with the tab name. Then you can use CF to highlight duplicates. But, in PQ you could also simply remove the duplicates if that is what you need to do.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.