Here are two of my existing macros for this task, perhaps one will suit you when adjusted. The first one should be faster on large datasets:
Sub DeleteDupesOnly()
'Deletes duplicates leaving complete list of unique values only
'Column B is evaluated
Dim LR As Long
'Data needs to start at row 2, so we'll insert a row
Rows(1).Insert (xlShiftDown)
LR = Range("B" & Rows.Count).End(xlUp).Row
Range("AA2:AA" & LR).FormulaR1C1 = "=COUNTIF(R2C2:RC2,RC2)"
Range("AA1") = "Key"
Range("AA1").AutoFilter Field:=1, Criteria1:=">1"
Range("AA2:AA" & LR).SpecialCells(xlCellTypeVisible).EntireRow.Delete
Rows(1).Delete (xlShiftUp)
Columns("AA:AA").Clear
End Sub
Sub DeleteDupesByLoop()
Dim LR As Long, MyCount As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
Application.EnableEvents = False
For i = LR To 2 Step -1
MyCount = WorksheetFunction.CountIf(Cells(i, "B"), Columns("B:B"))
If MyCount > 1 Then Rows(i).EntireRow.Delete Shift:=xlUp
MyCount = 0
Next i
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Bookmarks