help needed on multiple option buttons

P

paddy_ryan

Hi,
I am trying to use option buttons in a few different locations in Excel. In one cell i want three options and three different buttons. In another locations, two options with their own two buttons. However, the 5 buttons act as 5 linked options, so i can only have one or another button selected at a time. I would like one of the first three selected and one of the next two and so on. Can anybody help me work out how to resolve this.

Thanks,
 
D

Dave Peterson

If you used optionbuttons from the Forms toolbar, put a nice groupbox (also from
the forms toolbar) around each group.

If you use optionbuttons from the control toolbox toolbar, go into design mode
(icon on that same toolbar) and rightclick and provide a unique groupname
property for each option button.

(each optionbutton within the same group should have the same groupname--but
different than the other groups (did that last sentence help????))

The default groupname is the sheetname, so they're all grouped together.
 
P

paddy_ryan

dave, thanks, this seems to partially work (i used forms toolbar), once i grouped them first in the drawing toolbar. however, i have two remaining issues:

1. one of my option buttons stays selected no matter what i do
2. how do i make the group boxes go away (hide) so i can't see them?

thanks
 
P

paddy_ryan

OK, worked out my first problem, the group box was not dragged all the way around the option buttons, causing erratic behavior. I sitll can't get rid of those group boxes though.
 
D

Dave Peterson

You'll need to run a little VBA code:

Option Explicit
Sub GBVisibleToggle()
Dim myGB As GroupBox
For Each myGB In ActiveSheet.GroupBoxes
myGB.Visible = False 'true
Next myGB
End Sub

You can put it in another workbook so that you can run it against any worksheet
that you want. Just open the workbook and go to the real sheet and hit alt-f8
and double click the name of that macro.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Top