option buttons

G

gramps

-- I have a worksheet that shows a weeks roster for 2 locations. What I
would like to be able to do is to have 2 option buttons such that depending
on the selection the print area would be set and the appropriate locations
roster be printed.
OptionbuttonSW would set the print area as A$2:$H$9
OptionbuttonMW would set the print area as $A$11:$H$27

Al
 
J

Jim Thomlinson

In XL add the Contol Toolbox to your list of toolbars. Drag 2 option buttons
onto your sheet. Right click on of the buttons and change the (Name) to optSW
and the Caption to SW. Select the other button and make the (Name) optMW with
a Caption of MW. Double click either of the option buttons. This takes you to
the VBE with a on click code stub for that button. Add the following...

Private Sub optMW_Click()
Me.PageSetup.PrintArea = "A11:H27"
End Sub

Private Sub optSW_Click()
Me.PageSetup.PrintArea = "A1:H9"
End Sub

Now go back to the worksheet and exit design mode by clicking on the Ruler
and Triangle icon on the Control Toolbox...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top