ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   option buttons (https://www.excelbanter.com/excel-discussion-misc-queries/202602-option-buttons.html)

gramps

option buttons
 

-- 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

Jim Thomlinson

option buttons
 
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...
--
HTH...

Jim Thomlinson


"gramps" wrote:


-- 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



All times are GMT +1. The time now is 10:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com