[Solved] Deleting Duplicates EXCEL VBA Macro


This should work for you:

Sub DeleteDuplicates()
Dim lRow As Long
Dim i, j, k As Integer
Dim Duplicates() As Integer
Dim sht As Worksheet
Dim Val1, Val2 As String

Set sht = Worksheets("Sheet1")

lRow = sht.Cells(Rows.Count, 1).End(xlUp).Row
Index = 0

For i = 7 To lRow
    Val1 = sht.Cells(i, 1).Value
    Index = 0
    For j = i + 1 To lRow
        Val2 = sht.Cells(j, 1).Value
        If Val1 = Val2 Then
            ReDim Preserve Duplicates(Index)
            Duplicates(Index) = j
            Index = Index + 1
        End If
        If j = lRow Then
            If Index > 1 Then
                For k = UBound(Duplicates) - 1 To 0 Step -1
                    sht.Rows(Duplicates(k)).EntireRow.Delete
                Next k
            End If
        End If
    Next j
Next i
End Sub

0

solved Deleting Duplicates EXCEL VBA Macro