PDA

View Full Version : Solved: Delete entire row that are duplicates.



blastpwr1970
03-12-2007, 10:55 AM
Hi to all,:hi:

Could somebody help me, I need to delete rows that have duplicate numbers.

Thanks,

Bob Phillips
03-12-2007, 11:17 AM
Public Sub ProcessData()
Const TEST_COLUMN As String = "A"
Dim i As Long
Dim iLastRow As Long
Dim cell As Range
Dim sh As Worksheet
Dim rng As Range

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 2 To iLastRow
If Application.CountIf(.Cells(1, "C").Resize(i), .Cells(i, "C")) > 1 Then
If rng Is Nothing Then
Set rng = .Rows(i)
Else
Set rng = Union(rng, .Rows(i))
End If
End If
Next i

End With

If Not rng Is Nothing Then rng.Delete

End Sub

blastpwr1970
03-12-2007, 02:06 PM
It works great,
Thanks,
Julio