Trying to loop through each sheet and export to PDF if Cell A1 = 1, using ws name in PDF name
I got this far and was able to export all conditional to one PDF but can't get it to separate files, Currently script doesn't do anything and im stumped.
Any pointers where i've messed this up?
Thanks
AJ
I got this far and was able to export all conditional to one PDF but can't get it to separate files, Currently script doesn't do anything and im stumped.
VBA Code:
Public Sub Export_Sheets_To_PDF()
Dim saveInFolder As String
Dim replaceSelected As Boolean
Dim wsName As Variant
Dim ws As Worksheet
saveInFolder = "C:\Users\Documents\01-ReportFiles\"
'Save to onedrive
'saveInFolder = ThisWorkbook.Path
If Right(saveInFolder, 1) <> "\" Then saveInFolder = saveInFolder & "\"
With ThisWorkbook
replaceSelected = True
For Each ws In Worksheets
If Range("A1").Value = 1 Then
.Worksheets(ws).ExportAsFixedFormat Type:=xlTypePDF, Filename:=saveInFolder & .Worksheets("Master_00").Range("K2").Text & "_" & ws & "_" & Format(Date, "YYYY-MM-DD") & ".pdf", _
Quality:=xlQualityMinimum, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End If
Next
End With
End Sub
Any pointers where i've messed this up?
Thanks
AJ