Habe mal wieder ein kleines Problemchen.
Mit folgendem Code kopiere ich die Zeilen in WS2 nach WS3, die in Spalte N "CLOSED" enthalten. Funktioniert.
Nach dem Kopieren sollen diese Zeilen aber auch in WS2 geloescht werden. Funktioniert nur teilweise, denn es werden nicht alle Zeilen geloescht. Kann mir jemand sagen, wo ich hier mal wieder auf der Leitung stehe?
Vielen Dank im Voraus.
Sub closed_move()
Application.ScreenUpdating = False
Dim myRow As Long
Dim myLastRow1 As Long
Dim myLastRow2 As Long
Dim WS2 As Worksheet: Set WS2 = Worksheets("Main Sheet")
Dim WS3 As Worksheet: Set WS3 = Worksheets("CLOSED")
With WS2
myLastRow1 = .Cells(Rows.Count, 14).End(xlUp).Row
End With
For myRow = 2 To myLastRow1
If WS2.Cells(myRow, 14).Value = "CLOSED" Then
With WS3
myLastRow2 = .Cells(Rows.Count, 1).End(xlUp).Row
End With
WS2.Rows(myRow).Copy Destination:=WS3.Rows(myLastRow2 + 1)
WS2.Rows(myRow).EntireRow.Delete
End If
Next myRow