View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Programatically find Duplicate entries

This list both ends of the duplication

Sub Dups()
Dim iLastRow As Long
Dim i As Long
Dim sCells As String
Dim rng As Range

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range("A1:A" & iLastRow)
For i = 1 To iLastRow
If Application.CountIf(rng, Cells(i, "A")) 1 Then
sCells = sCells & Cells(i, "A").Address(False, False) & ","
End If
Next i
sCells = Left(sCells, Len(sCells) - 1)
MsgBox "Duplicates found in " & vbCrLf & sCells

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steph" wrote in message
...
Hello. I have some code that when a button is pushed, takes a list of

data
(columnA) and manipulates it. Is there a way to, upon pushing the button,
first perform a scan of columnA, and determine if there are duplicates in
that column? And ideally, identify in a message box which cells have
duplicate entries?

-Steph