我有一个因为块错误而无法运行的宏。据我所知,该块已完成。当我尝试运行时,Sub LoopThrough Directory()会突出显示为错误,我不太清楚为什么。
Sub LoopThroughDirectory()
Dim MyFile As Variant
Dim wkb As Workbook
Filepath = "\\WFSIADMNSF21\C_MTG_Groups\DAPLAVA\Monthly Vendor Files\Pres\"
MyFile = Dir(Filepath)
Do While Len(MyFile) > 0
If MyFile <> "PFORMAT.xlsm" Then
Application.DisplayAlerts = True
Set wkb = Workbooks.Open(Filepath & MyFile)
Application.DisplayAlerts = False
**I have 1500 lines of code between here, but no additional if statements, and nothing matches the indentation of the If statement**
End With
wkb.Close savechanges:=True
End If
MyFile = Dir
Loop
Sheets("PFORMAT").Select
End Sub