ich möchte das doppelte Datensätze gelöscht werden.
Bedingung wenn der Name bereits vorhanden (Alt) soll dieser gelöscht werden.
Leider funktioniert das nicht.
Danke!
Gruß
Ludmila
https://www.herber.de/bbs/user/122037.xlsm
Sub Zeilen_loeschen()
Dim rng As Range
Set rng = ActiveSheet.Range("G2:G20").Find(what:="Alt", lookat:=xlWhole)
If rng Is Nothing Then
Exit Sub
Else
rng.EntireRow.Delete
End If
Do
Set rng = ActiveSheet.Cells.FindNext
If rng Is Nothing Then
Exit Sub
Else
rng.EntireRow.Delete
End If
Loop
End Sub
MfG BerndPrivate Sub CommandButton1_Click()
Dim lxl&, lol&
With ThisWorkbook.Worksheets("BL")
lol = .Cells(Rows.Count, 3).End(xlUp).Row
.Cells(2, 1).Resize(lol - 1, 7).Sort _
Key1:=.Range("C2"), Order1:=xlAscending, _
Header:=xlNo, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
.Cells(2, 1).Resize(lol - 1, 7).Sort _
Key1:=.Range("F2"), Order1:=xlDescending, _
Header:=xlNo, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
lol = .Cells(Rows.Count, 3).End(xlUp).Row
For lxl = lol To 1 Step -1
If WorksheetFunction.CountIf(.Columns(3), .Cells(lxl, 3)) > 1 Then
If .Cells(lxl, 7) = "Alt" Then
Rows(lxl).Delete
End If
End If
Next lxl
lol = .Cells(Rows.Count, 3).End(xlUp).Row
.Cells(2, 1).Resize(lol - 1, 7).Sort _
Key1:=.Range("C2"), Order1:=xlAscending, _
Header:=xlNo, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
For lol = 2 To .Cells(Rows.Count, 3).End(xlUp).Row
.Cells(lol, 1) = lol
.Cells(lol, 7) = "Alt"
Next
End With
End Sub
Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden
Suche nach den besten AntwortenEntdecke unsere meistgeklickten Beiträge in der Google Suche
Top 100 Threads jetzt ansehen