Hi, I am trying to delete any duplicate row based on column "C" data.
I have sorted the data so the data is sorted by "C" the account number and then "E" the date with the eldest first.
When I run this code it does not pick up all the duplicates and does delete some that are not duplicates.
Worksheets("Raw Data wo ACT").Activate
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Lastrow3 = Cells(Rows.Count, "A").End(xlUp).Row
Range("A2", Cells(LastRow, 17)).Select
Selection.Sort Key1:=Range("E1"), Order1:=xlAscending _
, Key2:=Range("C1"), Order2:=xlAscending _
Count = 1
For x = Lastrow3 To 2 Step -1
If Cells(Lastrow3, 3).Value = Cells(Lastrow3 - 1, 3).Value Then
Range(Cells(Lastrow3, 3)).EntireRow.Delete
Count = Count + 1
End If
Next x
The sheets has about 7000 rows.
I have sorted the data so the data is sorted by "C" the account number and then "E" the date with the eldest first.
When I run this code it does not pick up all the duplicates and does delete some that are not duplicates.
Worksheets("Raw Data wo ACT").Activate
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Lastrow3 = Cells(Rows.Count, "A").End(xlUp).Row
Range("A2", Cells(LastRow, 17)).Select
Selection.Sort Key1:=Range("E1"), Order1:=xlAscending _
, Key2:=Range("C1"), Order2:=xlAscending _
Count = 1
For x = Lastrow3 To 2 Step -1
If Cells(Lastrow3, 3).Value = Cells(Lastrow3 - 1, 3).Value Then
Range(Cells(Lastrow3, 3)).EntireRow.Delete
Count = Count + 1
End If
Next x
The sheets has about 7000 rows.