Hi Roy,
Thank you very much, now it works!
Went through the Forum Rules too fast ( as usually
Will take a closer look and make sure to wrap in Code Tags next time
Again, Thank you!
Best regards
Fredrik
VBA Padawan
Hi Roy,
Thank you very much, now it works!
Went through the Forum Rules too fast ( as usually
Will take a closer look and make sure to wrap in Code Tags next time
Again, Thank you!
Best regards
Fredrik
VBA Padawan
The closest I can get is with this IF not statment, Now I can exclude the Source data sheet but still not the Template sheet,
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
If Not ws.Name <> "Template" Or ws.Name <> "Source data" Then
ws.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=ThisWorkbook.Path & "/" & ws.Name & ".pdf"
Else
End If
Next
End Sub
Display More
[xpost][/xpost]
https://www.mrexcel.com/board/…files-vba-coding.1195462/
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
Display More
I would be very grateful for any assistance
My best regards from a cold Sweden,
Fredrik