Highlight duplicates across all worksheets

Babay

New Member
Joined
Aug 22, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello forum!
I'm new to excel and hope you guys could help.
Currently I'm using Zoho sheets (sorry for post in Excel forum, but community in Zoho not such big as here and things are pretty same) and I need to update this simple script to make it search and always highlight all sheets in document. It's hard to every time change macro when I add extra sheet.

Code:
Sub highlightDups()    
    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    
    Dim maxOne As Long
    Dim maxTwo As Long
        
    
    Set ws1 = Sheets("One") 'change me
    Set ws2 = Sheets("Two") 'change me
    
    maxOne = ws1.Cells(Rows.count, "A").End(xlUp).Row
    maxTwo = ws2.Cells(Rows.count, "A").End(xlUp).Row
    
    
    For x = 2 To maxOne Step 1
        For y = 2 To maxTwo Step 1
        
            If ws1.Cells(x, 1) = ws2.Cells(y, 1) Then
                ws1.Cells(x, 1).Interior.ColorIndex = 3
                ws2.Cells(y, 1).Interior.ColorIndex = 3
                GoTo Skip
            End If
        
        Next y
Skip:
    Next x
    


End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Basically what I need is search and highlight duplicates in Sheet1 A1-End vs All other sheets.
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,835
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top