Hi everyone,
I have a spreadsheet with 20 worksheets in it. Everytime user completes any worksheets, the worksheet name comes through IF Formula to the admin sheet. I want to create PDF for whichver worksheets name are in the range from A1:A20. The "home" sheet is default pdf so hence the below code but not sure how to create PDF from the sheet names in the range. Please can someone guide me.
Many thanks
I have a spreadsheet with 20 worksheets in it. Everytime user completes any worksheets, the worksheet name comes through IF Formula to the admin sheet. I want to create PDF for whichver worksheets name are in the range from A1:A20. The "home" sheet is default pdf so hence the below code but not sure how to create PDF from the sheet names in the range. Please can someone guide me.
Many thanks
VBA Code:
Sub pdf_sh()
Dim i As Long, c As Long
Dim sheetarray() As String
Dim pdfName As String, fileSaveName As Variant
Dim default As Variant
default = Array("Home")
With Sheets("Home")
pdfName = .Range("B9").Value & "_" & .Range("B17")
ChDir "Test"
fileSaveName = Application.GetSaveAsFilename(pdfName, "PDF Files (*.pdf), *.pdf")
If fileSaveName <> False Then
Sheets(sheetarray()).Select
ActiveSheet.ExportAsFixedFormat xlTypePDF, fileSaveName, xlQualityStandard, True, False, , , True
.Select
End If
End With
End Sub