VBA 错误 编译错误:Next 没有 For

VBA 错误 编译错误:Next 没有 For

有人能帮我看看下面代码哪里出错了吗?我一直收到错误编译错误:Next without For。

Sub createPDFfiles()
    Dim ws As Worksheet
    Dim Fname As String
    Dim i, j As Integer
    For Each ws In ActiveWorkbook.Worksheets
    On Error Resume Next
    For i = 1 To 20
    j = 57
If (Cells(i, j)) = "1" Then
        Fname = "Annex 1.1." & ws.Index & "_result"

        ws.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            Filename:=Fname, _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False
Next

Else

        Next ws
End Sub

答案1

{如果,否则,结束如果}必须完全在为了环形。

相关内容