Identifying Duplicates and assigning a 'Rank'

Welsh Mark3

Board Regular
Joined
Apr 7, 2014
Messages
164
Office Version
  1. 365
I have a file with 1331 account ID's, I can use the count function to identify if an ID is duplicated, is there a way to identify which of the duplicates is the primary duplicate?

For the purpose of this, the primary would be defined as appearing first in the order (row number)
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Assuming the ID's are in column A starting in row 2, this macro will highlight in red the primary duplicate.
Code:
Sub FindPrimaryDup()
    Application.ScreenUpdating = False
    Dim Rng As Range, RngList1 As Object, RngList2 As Object, item As Variant, ID As Range
    Set RngList1 = CreateObject("Scripting.Dictionary")
    Set RngList2 = CreateObject("Scripting.Dictionary")
    For Each Rng In Range("A2", Range("A" & Rows.Count).End(xlUp))
        If Not RngList1.Exists(Rng.Value) Then
            RngList1.Add Rng.Value, Nothing
        Else
            RngList2.Add Rng.Value, Nothing
        End If
    Next Rng
    For Each item In RngList2
        Set ID = Range("A:A").Find(item)
        ID.Interior.ColorIndex = 3
    Next item
End Sub
 
Upvote 0
With a formula


Excel 2013/2016
AB
1Hole ID
22018PJAC001Primary
32018PJAC001
42018PJAC001
52018PJAC001
62018PJAC001
72018PJAC002Primary
82018PJAC002
92018PJAC002
102018PJAC002
112018PJAC002
122018PJAC003Primary
132018PJAC003
OrderCard
Cell Formulas
RangeFormula
B2=IF(COUNTIF(A$2:A2,A2)=1,"Primary","")
 
Upvote 0
With a formula

Excel 2013/2016
AB
Hole ID
2018PJAC001Primary
2018PJAC001
2018PJAC001
2018PJAC001
2018PJAC001
2018PJAC002Primary
2018PJAC002
2018PJAC002
2018PJAC002
2018PJAC002
2018PJAC003Primary
2018PJAC003

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"][/TD]

[TD="align: center"]2[/TD]

[TD="align: center"]3[/TD]

[TD="align: center"]4[/TD]

[TD="align: center"]5[/TD]

[TD="align: center"]6[/TD]

[TD="align: center"]7[/TD]

[TD="align: center"]8[/TD]

[TD="align: center"]9[/TD]

[TD="align: center"]10[/TD]

[TD="align: center"]11[/TD]

[TD="align: center"]12[/TD]

[TD="align: center"]13[/TD]

</tbody>
OrderCard

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]B2[/TH]
[TD="align: left"]=IF(COUNTIF(A$2:A2,A2)=1,"Primary","")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
Works perfectly Thank you
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

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