Hello, as the thread title says it all, I am trying to create a VBA code to highlight duplicates in a single column, was thinking of adding on a delete duplicate code too but I'm afraid of deleting the wrong duplicate thus I am highlighting them first, below is the code that I am using currently, but when I delete the duplicates, the cells stay coloured. So is there a better way of having them highlighted so that when the duplicates are deleted, the cells won't be highlighted anymore? Thank you in advance for the help!
VBA Code:
Private Sub DupeClean()
Application.ScreenUpdating = False
Dim r As Range, rr As Range
Dim Main As Worksheet
Dim i As Long
Set Main = ThisWorkbook.Sheets("Import")
i = Main.Range("D" & Rows.Count).End(xlUp).Row
Set rr = Main.Range("D2:D" & i)
For Each r In rr
If WorksheetFunction.CountIf(rr, r.Value) > 1 Then _
r.Interior.ColorIndex = 3
Next
Application.ScreenUpdating = True
End Sub