Makro geht in unendlich
07.04.2022 13:27:16
javiersc
ich habe ein Problem bei einer For...Next Anweisung und zwar dass ich nicht weiß wo ich die Exit for Anweisung schreiben soll damit der Makro nicht in unendlich geht.
Ich hoffe ihr könnt mir helfen!
Danke!
Anbei mein code:
Sub LeereZeile_Loeschen()
Dim i As Integer
Dim y As Integer
y = WorksheetFunction.CountIf(Range("A:A"), "WAHR")
ThisWorkbook.Worksheets("ExportTable").Range("A:A").EntireColumn.Delete
For i = 3 To y
If ThisWorkbook.Worksheets("ExportTable").Cells(i, 1) = "" Then
ThisWorkbook.Worksheets("ExportTable").Range(Cells(i, 1), Cells(i, 42)).Delete
i = i - 1
Else
If ThisWorkbook.Worksheets("ExportTable").Cells(i, 43) = "" Then
ThisWorkbook.Worksheets("ExportTable").Range(Cells(i, 43), Cells(i, 89)).Delete
i = i - 1
End If
End If
If ThisWorkbook.Worksheets("ExportTable").Cells(i, 1) = "" And ThisWorkbook.Worksheets("ExportTable").Cells(i, 43) = "" Then
Exit For
End If
Next i
End Sub