Hi all,
I am a bit new to VBA coding but have managed to create a macro that lets me save multiple worksheets to separate pdf's.
But, I don't want to include two specific sheets, for ex, sheet TEMPLATE and SOURCE DATA how can I exclude these two and print the rest?
This is my code:
Sub LoopSheetsSaveAsPDF()
'Create variables
Dim ws As Worksheet
'Loop through all worksheets and save as individual PDF in same folder
'as the Excel file
For Each ws In ActiveWorkbook.Worksheets
ws.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=ThisWorkbook.Path & "/" & ws.Name & ".pdf"
Next
End Sub
I would be very grateful for any assistance
My best regards from a cold Sweden,
Fredrik
I am a bit new to VBA coding but have managed to create a macro that lets me save multiple worksheets to separate pdf's.
But, I don't want to include two specific sheets, for ex, sheet TEMPLATE and SOURCE DATA how can I exclude these two and print the rest?
This is my code:
Sub LoopSheetsSaveAsPDF()
'Create variables
Dim ws As Worksheet
'Loop through all worksheets and save as individual PDF in same folder
'as the Excel file
For Each ws In ActiveWorkbook.Worksheets
ws.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=ThisWorkbook.Path & "/" & ws.Name & ".pdf"
Next
End Sub
I would be very grateful for any assistance
My best regards from a cold Sweden,
Fredrik