The_Steward
Board Regular
- Joined
- Nov 26, 2020
- Messages
- 63
- Office Version
- 365
- Platform
- Windows
Hey,
I want to save two different ranges into a PDF document. One range for each page.
The first range is Worksheets("Data Storage").Range("$N$4:$P$20") = Range for First Page
The second range is Worksheets("Data Storage").Range("$Z$32:$AG$97") = Range for Second Page (The Range in Macro Below)
The Macro below works for one range, but can't seem to make it work for an array yet.
I also want to only include first page when a Checkbox in one of userforms is clicked.
The name of the Checkbox in the userform is CheckBox_AddBDetails
The Name of the Userform is SOSCustomiser
Any help is greatly appreciated.
I want to save two different ranges into a PDF document. One range for each page.
The first range is Worksheets("Data Storage").Range("$N$4:$P$20") = Range for First Page
The second range is Worksheets("Data Storage").Range("$Z$32:$AG$97") = Range for Second Page (The Range in Macro Below)
The Macro below works for one range, but can't seem to make it work for an array yet.
VBA Code:
Sub SaveAsPDF()
Dim filePath As Variant
Dim exportRange As Range
'Set the export range to the specified array in the "Data Storage" worksheet
Set exportRange = Worksheets("Data Storage").Range("$Z$32:$AG$97")
'Open the save dialog box
filePath = Application.GetSaveAsFilename(fileFilter:="PDF Files (*.pdf), *.pdf", Title:="Save As PDF")
'Check if user has cancelled the dialog box
If filePath = False Then Exit Sub
'Save the export range as PDF file
exportRange.ExportAsFixedFormat Type:=xlTypePDF, Filename:=filePath, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
'Open the PDF file if it was saved successfully
If Dir(filePath) <> "" Then
ActiveWorkbook.FollowHyperlink filePath
End If
End Sub
I also want to only include first page when a Checkbox in one of userforms is clicked.
The name of the Checkbox in the userform is CheckBox_AddBDetails
The Name of the Userform is SOSCustomiser
Any help is greatly appreciated.