VBA error Compile error: Next without For

Eric

Can somebody please assist me and seeing what I did wrong on the code below. I keep getting error Compile error: 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
Gary's Student

The {If, Else, End If} must be completely within the For loop.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related