Working with GroupName in a control

A

Ayo

I have 2 forms. On both forms I have option buttons. Form1 has 4
optionbuttons: Central, Northeast, South and West. Form2 has 4 Frames for
each region and in each frame I have between 10 to 20 markets.
My objective is: Whan I click on any of the region optionbuttons on form1,
I want to open form2 with only the region's frame enabled, along with all the
markets optionbuttons within the frame. At the same time, I want the other
three region frames and all their respective market optionbuttons to be
disabled.
So far this is where I am and I am stuck:

Private Sub optCentral_Click()
Dim ctl As Control
UserForm2.frmNortheast.Enabled = False
UserForm2.frmSouth.Enabled = False
UserForm2.frmWest.Enabled = False
Me.Hide
'currSheet.Range("B1").Select
For Each ctl In UserForm2.Controls
'if Typename(ctl)="OptionButton"
Next ctl
UserForm2.Show
End Sub

I don't know what my IF statement should include. Any help or ideas will be
appreciated.
Thanks
 
A

Ayo

Thanks . I figured it out:
Dim ctl As Control
UserForm2.frmNortheast.Enabled = False
UserForm2.frmSouth.Enabled = False
UserForm2.frmWest.Enabled = False
Me.Hide
currSheet.Range("B1").Select
For Each ctl In UserForm2.Controls
If TypeName(ctl) = "OptionButton" Then
If ctl.GroupName <> optCentral.Caption Then
ctl.Enabled = False
End If
End If
Next ctl
UserForm2.Show
Application.ScreenUpdating = True
 

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