sharky12345
Well-known Member
- Joined
- Aug 5, 2010
- Messages
- 3,422
- Office Version
- 2016
- Platform
- Windows
Can anyone tell me if it is possible to group Option buttons that are in different frames on a userform?
Can anyone tell me if it is possible to group Option buttons that are in different frames on a userform?
Option Explicit
Public WithEvents OptBtn As MsForms.OptionButton
Private oUForm As UserForm
Private DisableEvents As Boolean
Public Property Get GetUserForm() As UserForm
Set GetUserForm = oUForm
End Property
Public Property Set GetUserForm(ByVal vNewValue As UserForm)
Set oUForm = vNewValue
End Property
Private Sub OptBtn_Change()
Dim oCtrl As Control
For Each oCtrl In GetUserForm.Controls
If TypeOf oCtrl Is MsForms.OptionButton Then
If oCtrl.Tag = "Grouped" Then
If Not oCtrl Is OptBtn Then
If DisableEvents = False Then
oCtrl.Value = Not OptBtn.Value
End If
End If
End If
End If
Next
DisableEvents = True
End Sub
Option Explicit
Private oCollection As New Collection
Private Sub UserForm_Initialize()
Dim oCtrl As Control
Dim oClassInstance As C_OptionEvents
For Each oCtrl In Me.Controls
If TypeOf oCtrl Is MsForms.OptionButton Then
oCtrl.Tag = "Grouped"
Set oClassInstance = New C_OptionEvents
Set oClassInstance.OptBtn = oCtrl
Set oClassInstance.GetUserForm = Me
oCollection.Add oClassInstance
End If
Next
End Sub
Hi sharky12345,I'll give that a try - thank you!