Using a dynamic list to print selected sheets

riazd

New Member
Joined
May 7, 2015
Messages
18
Hi

I've written a code to print specific sheets based on the name, viz.


Sub MyPrint()

Windows("161082.xlsm").Activate
Sheets(Array("P026", "P062", "P125", "P461", "P645", "P721", "PMF15", "PMF57", "PMF62", "PMF65", "PMF66")).Select
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="C:\Users\riazd.PLAZA\Desktop\Payslips" & "SCS Lynette", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False

Sheets(Array("P021", "P028", "P056", "P356", "P557")).Select
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="C:\Users\riazd.PLAZA\Desktop\Payslips" & "Wrap", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False

End Sub

The macro runs perfectly, but i would like to enhance it by



  1. Using lists on a control sheet to populate the sheet names based on a dynamic range e.g. A2:A13 is the first print parameters B3:B7 is the second print parameters ect.
  2. Use the header row to name the output file e.g. A1 is SCS LL B1 is Wrap


Any help will be appreciated,
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,215,429
Messages
6,124,845
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top