Select Multiple Worksheets to Print in VBA

EasterGreen

Board Regular
Joined
Sep 7, 2009
Messages
50
I have borrowed VBA code from various posts here to run a batch print job to pdf using data from a drop down list.
I now want to print to pdf sheets 2-4 (which are driven by the input to A8) instead of sheet 1 and cannot get it to work.
The drop down is in cell A8 on sheet 1 and I have assigned a macro button on sheet 1.
How do I make it print sheets 2,3,4 instead of sheet 1?

Thanks

Sub Print_All_Managers()

Dim inputRange As Range
Dim i As Range

Set inputRange = Evaluate(Range("A8").Validation.Formula1)

For Each i In inputRange

Range("A8").Value = i.Value

Activate.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="C:\Users\xxx\" & i.Value, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False

Next i


End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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