Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Option buttons in two levels groups
Hi,
I have about 50 options buttons that are grouped in 8 main groups accessible through 8 main level option buttons. Once a main level option button is selected, a sub level group appears (the other ones become invisible) for the user to select a sub level option. There is a default option on both levels so that there is always a selection in both levels. I need to find the sub level option button that is selected to continue the process. I came upon this code from Rick Rothstein (commented by Dave Peterson) and adapted it to suit my case but I always get options from the first subgroup. The last one selected remains the one that will come out. I cannot get any of the others even though they are visible and selected. What could be the problem? Here is the code: Dim ctrOb As Control Dim ctrObSelected As msforms.OptionButton ' On Error Resume Next For Each ctrOb In Controls If TypeOf ctrOb Is msforms.OptionButton Then If ctrOb.GroupName < "grpCompte" And _ ctrOb.GroupName < "grpDrpTypeTransac" And _ ctrOb.GroupName < "grpDrpTransfert" And _ ctrOb.GroupName < "grpTypeTransac" Then If ctrOb.Value = True Then Set ctrObSelected = ctrOb Exit For End If End If End If Next If Err.Number 0 Then MsgBox "No OptionButton selected" Else MsgBox "ctrObSelected.Name = " & ctrObSelected.Name & _ vbCrLf & "ctrObSelected.Caption = " & ctrObSelected.Caption End If Thank you. -- Jac Tremblay |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Option buttons in two levels groups
Hi, it's me...
I found a simple solution. In a separate procedure where I hide all the subgroups before I display the one selected, I added some code to deselect all options. It goes like that and works fine. Dim ctrOb As Control For Each ctrOb In Controls If TypeOf ctrOb Is msforms.OptionButton Then If ctrOb.GroupName < "grpCompte" Then If ctrOb.Value = True Then ctrOb.Value = False End If End If Next I was inspired by Rick and Dave. Thanks to them. I thought I posted this for the benefit of the community. Good night to everyone. -- Jac Tremblay "Jac Tremblay" wrote: Hi, I have about 50 options buttons that are grouped in 8 main groups accessible through 8 main level option buttons. Once a main level option button is selected, a sub level group appears (the other ones become invisible) for the user to select a sub level option. There is a default option on both levels so that there is always a selection in both levels. I need to find the sub level option button that is selected to continue the process. I came upon this code from Rick Rothstein (commented by Dave Peterson) and adapted it to suit my case but I always get options from the first subgroup. The last one selected remains the one that will come out. I cannot get any of the others even though they are visible and selected. What could be the problem? Here is the code: Dim ctrOb As Control Dim ctrObSelected As msforms.OptionButton ' On Error Resume Next For Each ctrOb In Controls If TypeOf ctrOb Is msforms.OptionButton Then If ctrOb.GroupName < "grpCompte" And _ ctrOb.GroupName < "grpDrpTypeTransac" And _ ctrOb.GroupName < "grpDrpTransfert" And _ ctrOb.GroupName < "grpTypeTransac" Then If ctrOb.Value = True Then Set ctrObSelected = ctrOb Exit For End If End If End If Next If Err.Number 0 Then MsgBox "No OptionButton selected" Else MsgBox "ctrObSelected.Name = " & ctrObSelected.Name & _ vbCrLf & "ctrObSelected.Caption = " & ctrObSelected.Caption End If Thank you. -- Jac Tremblay |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Accessing groups of option buttons | Excel Programming | |||
Groups in Option buttons | Excel Programming | |||
with multiple option buttons on my form how do I isolate groups | Excel Worksheet Functions | |||
Two Groups of Option Buttons on Worksheet | Excel Discussion (Misc queries) | |||
Option Buttons - groups | Excel Discussion (Misc queries) |