Sehr konfortabel (Beispiel für Datensatz über Spalten A,B,C)
___________________________________________
Option Explicit
Public Sub DuplikateLoeschenSort()
Dim xlWS As Worksheet
Dim xlRange As Range
Dim intColsCnt As Integer
Dim lngRowsCnt As Long
Dim intCol As Integer
Dim lngRow As Long
Dim lngRowsDel As Long
Dim boolDuplikat As Boolean
Application.ScreenUpdating = False
Set xlWS = ActiveSheet
With xlWS
intColsCnt = .UsedRange.Columns.Count
lngRowsCnt = .UsedRange.Rows.Count
Set xlRange = _
.Range(.Cells(1, 1), .Cells(lngRowsCnt, intColsCnt))
xlRange.Sort Key1:=.Range(„A1“), Order1:=xlAscending, _
Key2:=.Range(„B1“), Order2:=xlAscending, _
Key3:=.Range(„C1“), Order3:=xlAscending, _
Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End With
xlWS.Range(„A1“).Select
lngRowsDel = 0
For lngRow = lngRowsCnt To 2 Step -1
boolDuplikat = True
With xlWS
For intCol = 1 To intColsCnt
If .Cells(lngRow, intCol).Value _
.Cells(lngRow - 1, intCol).Value Then
boolDuplikat = False
Exit For
End If
Next intCol
If boolDuplikat Then
.Rows(lngRow).EntireRow.Delete
lngRowsDel = lngRowsDel + 1
End If
End With
Next lngRow
Application.ScreenUpdating = True
MsgBox "Es wurden " & lngRowsDel & " doppelte " & _
„Datensätze gelöscht!“, vbOKOnly + vbInformation, _
Title:=„Doppelte Datensätze löschen“
Set xlRange = Nothing
Set xlWS = Nothing
End Sub
[Bei dieser Antwort wurde das Vollzitat nachträglich automatisiert entfernt]