I am trying to save four sheets into a single PDF. The code below is what I have so far. When I use the ActiveSheet.Name command in the file name it works, however when I change it to a range for a cell that is dynamic it no longer works and errors out. Any help would be appreciated.
Sheets(Array("Dashboard Pg 1", "Dashboard Pg 2", "Dashboard Pg 3", _
"Dashboard Pg 4")).Select
Sheets("Dashboard Pg 1").Activate
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\Allen\Desktop\Projects\" & ActiveSheet.Range("K17").Value & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Sheets("Summary").Select
Filename:="C:\Users\Allen\Desktop\Projects\" & ActiveSheet.Range("K17").Value & ".pdf"
)? – PatricK.Value
, the date will be represented as a short date with forward slashes which cannot be used in a filename. UseActiveSheet.Range("K17").Text
to get the formatted value from the cell. Make sure that the cell is wide enough to display the full formatted text or you will end up with ###### as your PDF filename. – user4039065Format(ActiveSheet.Range("K17"),"YYYY-MM-DD")
– MMerry