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
(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