Duplicate Items in a Column ... number of rows displayed.

rdeugau

New Member
Joined
Jun 9, 2015
Messages
1
This works good .. but I need it to display the number (total) of rows (or total instances of duplicate found) not the row numbers where duplicate is.
(could be up to 50,000 rows but one column.)



Sub Check_Names()
Dim dict As Object
Dim LR As Long, i As Long, v As Variant, strResult As String

Set dict = CreateObject("Scripting.Dictionary")

With Sheets("Sheet1")
LR = .Range("A" & .Rows.Count).End(xlUp).Row
For i = 1 To LR
If WorksheetFunction.CountIf(.Columns("A"), .Range("A" & i).Value) > 1 Then
If dict.Exists(.Range("A" & i).Value) Then
dict.Item(.Range("A" & i).Value) = dict.Item(.Range("A" & i).Value) & .Range("A" & i).Row & ","
Else
dict.Add .Range("A" & i).Value, .Range("A" & i).Row & ","
End If
End If
Next i
End With

For Each v In dict.keys
strResult = strResult & "Duplicate Name: " & v & vbNewLine & "Rows: " & _
Left(dict.Item(v), Len(dict.Item(v)) - 1) & vbNewLine & vbNewLine
Next v
MsgBox strResult

End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,091
Latest member
gaurav_7829

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