Block if without end if - wo?
10.11.2020 10:51:26
Nils
ich hab leider den typischen "block if without end if" Fehler aber ich kann einfach nicht erkennen, wo das end if hingehört? Kann hier jemand einem Anfänger mal auf die Sprünge helfen? vielen Dank vorab!
strDateiname4m = Dir$(strPath4m & "\*.xlsx")
Do While strDateiname4m ""
If strDateiname4m ThisWorkbook.Name Then
Set wkbBook = Workbooks.Open(strPath4m & strDateiname4m)
With ActiveWorkbook.Worksheets("RawDataProjectDays")
lastrow = .Cells(Rows.Count, 1).End(xlUp).Row
For i = lastrow To 2 Step -1
If ActiveWorkbook.Worksheets("RawDataProjectDays").Cells(i, 5) = 2020 Then
.Rows(i).Delete
End If
Next
End With
With ActiveWorkbook.Worksheets("RawDataConsSw")
lastrow = .Cells(Rows.Count, 1).End(xlUp).Row
For i = lastrow To 2 Step -1
If ActiveWorkbook.Worksheets("RawDataConsSw").Cells(i, 5) = 2020 Then
.Rows(i).Delete
End If
Next
End With
strDateiname = Dir$(strPath & "\*.xlsx")
Do While strDateiname ""
If strDateiname ThisWorkbook.Name Then
Set wkbBook = Workbooks.Open(strPath & strDateiname)
With ActiveWorkbook.Worksheets("RawData")
lastrow = .Cells(Rows.Count, 1).End(xlUp).Row
For i = lastrow To 2 Step -1
If ActiveWorkbook.Worksheets("RawData").Cells(i, 5) = 2020 Then
.Rows(i).Delete
End If
Next
End With
wkbBook.Close True ' Oder false, wenn nicht gespeichert werden soll
Set wkbBook = Nothing
End If
strDateiname = Dir$()
Loop
Application.ScreenUpdating = True
End Sub