I see, did not know that there's a requirement to keep only the last duplicate record.
This solution replaces with values (no deletion of rows), so it could be faster:
Sub Duplicate()
Dim objMyUniqueEntries As Object
Dim lngRowStart As Long, _
lngRowEnd As Long, _
lngMyRow As Long, _
lngMyCounter As Long
Dim a, b, i As Long
Sheets("overview").Select
Set objMyUniqueEntries = CreateObject("Scripting.Dictionary")
lngRowStart = 36 'Starting row number for the data. Change to suit.
lngRowEnd = Range("A:A").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
Application.ScreenUpdating = False
With Sheets("overview").Range("A" & lngRowStart & ":H" & lngRowEnd)
a = .Value
For lngMyRow = UBound(a, 1) To LBound(a, 1) Step -1
If Not objMyUniqueEntries.Exists(a(lngMyRow, 1)) And a(lngMyRow, 1) <> "" Then
lngMyCounter = lngMyCounter + 1
objMyUniqueEntries.Item(a(lngMyRow, 1)) = 1
End If
Next lngMyRow
ReDim b(1 To lngMyCounter, 1 To UBound(a, 2))
For lngMyRow = UBound(a, 1) To LBound(a, 1) Step -1
If objMyUniqueEntries.Exists(a(lngMyRow, 1)) Then
objMyUniqueEntries.Remove (a(lngMyRow, 1))
For i = LBound(a, 2) To UBound(a, 2)
b(lngMyCounter, i) = a(lngMyRow, i)
Next
lngMyCounter = lngMyCounter - 1
End If
Next lngMyRow
.ClearContents
.Resize(UBound(b, 1)).Value = b
End With
Set objMyUniqueEntries = Nothing
Application.ScreenUpdating = True
End Sub
Bookmarks