Sub PrintSheets()
Dim i As Integer
Dim sht As Worksheet
Dim pdfPath As String
Dim bolSkipK As Boolean, bolSkipL As Boolean
On Error GoTo errHandler
Application.ScreenUpdating = False
pdfPath = ThisWorkbook.Path & "\"
If UCase(range("K10")) = "ON" Then
For i = 4 To 9
Set sht = Sheets(CStr(range("M" & i)))
sht.ExportAsFixedFormat Type:=xlTypePDF, Filename:=pdfPath & range("M" & i), Quality:=xlQualityStandard
Next
bolSkipK = True
End If
If UCase(range("L10")) = "ON" Then
For i = 4 To 9
Set sht = Sheets(CStr(range("N" & i)))
sht.ExportAsFixedFormat Type:=xlTypePDF, Filename:=pdfPath & range("N" & i), Quality:=xlQualityStandard
Next
bolSkipL = True
End If
If Not bolSkipK Then
For i = 4 To 9
If UCase(range("K" & i)) = "ON" Then
Set sht = Sheets(CStr(range("K" & i).Offset(0, 2)))
sht.ExportAsFixedFormat Type:=xlTypePDF, Filename:=pdfPath & range("M" & i), Quality:=xlQualityStandard
End If
Next
End If
If Not bolSkipL Then
For i = 4 To 9
If UCase(range("L" & i)) = "ON" Then
Set sht = Sheets(CStr(range("L" & i).Offset(0, 2)))
sht.ExportAsFixedFormat Type:=xlTypePDF, Filename:=pdfPath & range("N" & i), Quality:=xlQualityStandard
End If
Next
End If
exitHere:
Set sht = Nothing
Exit Sub
errHandler:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume exitHere
End Sub