cjohnson0181
New Member
- Joined
- Mar 29, 2018
- Messages
- 9
All, I currently have a macro that we use to print 4 sheets to PDF. However, we are now wanting to copy only the sheets that contain data in cell C25. (If Trans Sh 1 and 2 are not " ", then copy only those two sheets and create a new workbook). I would like to be able to choose the filename and location once the macro runs rather than saving to a specific location since I'll be sharing this with a couple friends. I'm thinking you probably can't do all of this in one macro but it would be awesome if I could!
Code:
Sub SaveSpecificToPDF()
Dim PdfFilename As Variant
PdfFilename = Application.GetSaveAsFilename( _
InitialFileName:="GGS Transmittal 0XX", _
FileFilter:="GGS Transmittal, *.pdf", _
Title:="Save As PDF")
Sheets(Array("Trans Sh 1", "Trans Sh 2", "Trans Sh 3", "Trans Sh 4")).Select
If PdfFilename <> False Then
With ActiveSheet.PageSetup
.Orientation = xlPortrait
.PrintArea = "$A$1:$K$49"
.Zoom = False
.FitToPagesTall = False
.FitToPagesWide = 1
End With
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=PdfFilename, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
From:=1, _
To:=5, _
OpenAfterPublish:=True
End If
End Sub