Code:
Option Explicit
Sub Macro1()
Sheets("Sheet1").Activate
ActiveSheet.UsedRange.Select
Sheets("Sheet2").Activate
ActiveSheet.UsedRange.Select
Sheets("Sheet3").Activate
ActiveSheet.UsedRange.Select
ThisWorkbook.Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\My\Desktop\Test.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub
I think this is right on path for what I'm trying to do, but it's not working for some reason. I made the following changes and my code is below. I'm getting an error on the first line.
Note that I removed the quotations for the sheets. People change the sheet names, so I need to address the sheets by the sheet number and not the name.
The error says "Type Mismatch" and it's on the first line of code.?.?
Sub Macro1()
Sheets(Sheet2).Activate
ActiveSheet.UsedRange.Select
Sheets(Sheet6).Activate
ActiveSheet.UsedRange.Select
Sheets(Sheet9).Activate
ActiveSheet.UsedRange.Select
ThisWorkbook.Sheets(Array(Sheet2, Sheet6, Sheet9)).Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\My\Desktop\Test.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub
Thanks,
Kelsey