I’ve tried the below, but what it does it apply the range I specify in Sheet1 to ALL the other sheets. I’ve also tried using ActiveSheet.UsedRange.Select for each sheet, but that includes extraneous cells that I don’t want displayed in the PDF. Does anyone have any ideas? I’m running Office 365 on Windows.
Sub SaveRangesAsPDF()
Sheets("Sheet1").Activate
ActiveSheet.Range("A1:L42").Select
Sheets("Sheet2").Activate
ActiveSheet.Range("A1:G35").Select
ThisWorkbook.Sheets(Array("Sheet1", "Sheet2")).Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Worksheets("Sheet3").Range("A2").Value, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub
Thanks so much!
>Solution :
There is no option to print selections on multiple sheets. You can choose one of:
- Selection on a single sheet.
- Active sheet(s) – an active sheet or selected sheets considering the printing area or not.
- Entire workbook – all sheets considering the printing area or not.
The solution for you is to define the printing area on each sheet and print selected sheets.
Sheet1.PageSetup.PrintArea = "$A$1:$L$42"
Sheet2.PageSetup.PrintArea = "$A$1:$G$35"
Sheets(Array("Sheet1", "Sheet2")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Worksheets("Sheet3").Range("A2").Value, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True