VBA for Printing from Drop Down List

soggy40

New Member
Joined
Jan 29, 2010
Messages
49
I have been trying to create a VBA from command button that allows me to print all from a drop down list (one sheet per item on the drop down list). I am at this point but have an error and can't figure it out.

Any help greatfully received

Private Sub CommandButton1_Click()
Sub Iterate_Through_data_Validation()
Dim xRg As Range
Dim xCell As Range
Dim xRgVList As Range
Set xRg = Worksheets("Summer - Revision").Range("C1")
Set xRgVList = Evaluate(xRg.Validation.Formula1)
For Each xCell In xRgVList
xRg = xCell.Value
ActiveSheet.PrintOut
Next
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
What and where is the error occuring?

You get xRg as a value but you're just printing the same sheet each time. If you want it to cycle through the data validation items in cell C1 you'd need
Code:
xRg.Value = xCell.Value
You set xRg to C1 as a range, but then the loop resets the value of the variable xRg to the value in the data validation list, you're not putting xCell.Value into the xRg range value if that makes sense

HTH
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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