I have an excel model that dynamically changes the number and names of ranges based on input from the user. All named ranges are then populated on a reference tab with their location in a corresponding cell. I need to write a macro that PDFs each of the named ranges on individual pages, but as a singular PDF file.
I have tried all of the forums that I can find that show various ways to PDF ranges, but nothing solves for two particular problems cohesively:
1) The number of named ranges will dynamically change. I cannot statically name them in my VBA code. 2) The named ranges are on 10 separate worksheets. 3) Some of the sheets have multiple named ranges on them. It's not always one-to-one, meaning I need it to PDF multiple named ranges from the same sheet, but the result must still be one named range per PDF'd page.
Can someone help me take the below list and accomplish my goal of creating one PDF file with a singular page for each named range? For reference, my named range table looks like the below:
Named Range, Location
Range1, =Sheet1!$K$2:$R$21
Range2, =Sheet2!$K$2:$R$21
Range3, =Sheet3!$K$2:$R$21
Range4, =Sheet4!$K$2:$R$21
Range5, =Sheet5!$K$2:$R$21
Range6, =Sheet6!$K$2:$R$21
Range7, =Sheet7!$K$2:$R$21
Range8, =Sheet8!$K$2:$R$21
Range9, =Sheet9!$K$2:$R$21
Range10, =Sheet10!$B$2:$I$21
Range10, =Sheet10!$K$2:$R$21
I've attempted multiple angles at this problem. I've attempted to move all named ranges to one tab, but this is very difficult because the named ranges have different formatting, meaning it's not as simple as copy and paste. I'm hesitant to show any code here because the 20 iterations I've tried have come nowhere close to accomplishing my goal. Any guidance structurally on how to do this is VERY VERY appreciated.
The end result I hope for is a macro that PDFs all named ranges from an excel workbook with each named range getting its own page in the PDF file.