VBA for Duplicates Across 13 Columns

mrsbrannon

Board Regular
Joined
Mar 7, 2018
Messages
61
Hello everyone,

I am trying to get a VBA code that will highlight duplicates found across 13 columns of data, possibly 100+ rows of data. So I'm looking for duplicated rows across those 13 columns. See below:

NameDOBAddressPhoneEtcEtcEtcEtcEtcEtcEtcEtcEtc
John Brown1/1/1992123 main1234
John Brown1/1/1992123 main1234

<tbody>
</tbody>

Please note that my data for checking starts in column C, not A. So it's Columns C thru O.

Thank you!:):)
 
Last edited:

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hello everyone,

I am trying to get a VBA code that will highlight duplicates found across 13 columns of data, possibly 100+ rows of data. So I'm looking for duplicated rows across those 13 columns. See below:

NameDOBAddressPhoneEtcEtcEtcEtcEtcEtcEtcEtcEtc
John Brown1/1/1992123 main1234
John Brown1/1/1992123 main1234

<tbody>
</tbody>

Please note that my data for checking starts in column C, not A. So it's Columns C thru O.

Thank you!:):)

Why not just use conditional format? Otherwise check out xlsupertool Sheet_Comparer rodericke.com/xlsuper
 
Upvote 0
A couple of questions:

1. Can you be more specific about how you are defining what a "duplicate" is? Only names? Only rows? That kind of thing.
2. What do you want to have happen when a duplicate is identified?
 
Upvote 0
NamePhoneStateCityAgeHeightFav. ColorFav. CandyFav. FoodBlood TypeHair ColorEye ColorCoffee or Tea
John Brown
1234LANew Orleans155'2BlueNerdsItalianO+BrownBlueCoffee
John Brown1234LANew Orleans155'2BlueNerdsItalianO+BrownBlueCoffee

<tbody>
</tbody>


1. The sample table shows kinda what I'm looking for in a duplicate. I want to find identical rows (duplicates) across all 13 of those columns. The headers are not these, but this is an idea of how the data lays out (starting with column C)

2. I want it to highlight the duplicate(s) AND original in YELLOW when found

Does that help?
 
Upvote 0
How about
Code:
Sub HighlightDupes()

   Dim Cl As Range
   Dim ValU
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("C2", Range("C" & Rows.Count).End(xlUp))
         ValU = Join(Application.Transpose(Application.Transpose(Cl.Resize(, 13).Value)), ",")
         If Not .exists(ValU) Then
            .Add ValU, Cl
         Else
            .Item(ValU).Resize(, 13).Interior.Color = vbYellow
            Cl.Resize(, 13).Interior.Color = vbYellow
         End If
      Next Cl
   End With
End Sub
 
Upvote 0
How about
Code:
Sub HighlightDupes()

   Dim Cl As Range
   Dim ValU
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("C2", Range("C" & Rows.Count).End(xlUp))
         ValU = Join(Application.Transpose(Application.Transpose(Cl.Resize(, 13).Value)), ",")
         If Not .exists(ValU) Then
            .Add ValU, Cl
         Else
            .Item(ValU).Resize(, 13).Interior.Color = vbYellow
            Cl.Resize(, 13).Interior.Color = vbYellow
         End If
      Next Cl
   End With
End Sub


Thank you! That works when I run the Macro. Is there a way to automate it? Also, is there a way to have it recognize if the rows are totally blank and not highlight duplicate blanks?
 
Upvote 0
This will ignore any row if col C is blank
Code:
Sub HighlightDupes()

   Dim Cl As Range
   Dim ValU
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("C2", Range("C" & Rows.Count).End(xlUp))
         If Len(Cl) > 0 Then
            ValU = Join(Application.Transpose(Application.Transpose(Cl.Resize(, 13).Value)), ",")
            If Not .exists(ValU) Then
               .Add ValU, Cl
            Else
               .Item(ValU).Resize(, 13).Interior.Color = vbYellow
               Cl.Resize(, 13).Interior.Color = vbYellow
            End If
         End If
      Next Cl
   End With
End Sub
As for automating it, when would you want it to run?
 
Upvote 0
I guess when the sheet is opened? The data is collected/pulled over daily/weekly. So either as it's opened or as the data is added? I'm not sure how to phrase that correctly.
 
Upvote 0

Forum statistics

Threads
1,215,261
Messages
6,123,948
Members
449,134
Latest member
NickWBA

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