AW: finde Wort lösche folgenden 5 Zeilen
15.02.2022 17:54:16
GerdL
Moin Michael,
teste mal-
Sub Unit()
Const strSearch As String = "ddd" 'anpassen
Dim rngFind As Range, rngDelete As Range, strFirstaddress As String
With Tabelle1.Columns("B") 'ggf.anpassen
Set rngFind = .Find(what:=strSearch, LookIn:=xlValues, lookat:=xlPart, MatchCase:=False)
If Not rngFind Is Nothing Then
strFirstaddress = rngFind.Address
Do
If rngDelete Is Nothing Then
Set rngDelete = rngFind.Resize(5, 1)
Else
Set rngDelete = Union(rngDelete, rngFind.Resize(5, 1))
End If
Set rngFind = .FindNext(rngFind)
Loop Until rngFind.Address = strFirstaddress
End If
If Not rngDelete Is Nothing Then rngDelete.EntireRow.Delete
Set rngFind = Nothing: Set rngDelete = Nothing
End With
End Sub
Gruß Gerd