I want to be able to save multiple specific worksheets to a PDF.
I currently have this code which works:
Sheets(Array("Print - Cover", "Print 2.2")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFFile,Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=OpenPDFAfterCreating
This saves sheets "Print - Cover" and "Print 2.2" to a PDF as intended. Instead of hardcoding the sheetnames, I would like to save whichever worksheets have a name that exists within a range of cells.
E.g. in cells A1:A3
of my ActiveSheet, I could have Bee, Cat and Dog, and the macro would
- select worksheets "Bee", "Cat" and "Dog",
- but not "Pig", which exists as a worksheet but isn't listed.
The number of sheets listed may increase or decrease.
The purpose of this is to allow users to easily indicate which sheets they would like saved without having to edit the macro.