Dim Ctrl As Control
For Each Ctrl In Me.Controls
Select Case TypeName(Ctrl)
Case "OptionButton"
If Not Ctrl Then
MsgBox Ctrl.Name & " Must be set"
Ctrl.SetFocus
Exit For
End If
Case "CombBox"
Case "TextBox"
End Select
Next
Dim CountOfFilledControls as Long
Dim oneControl as msForms.Control
For Each OneControl in Userform1.Controls
Select Case TypeName(OneControl)
Case "OptionButton"
If oneControl.Value Then CountOfFilledControls = CountOfFilledControls + 1
Case "TextBox", "ComboBox", "RefEdit", "ListBox"
If oneControl.Text <> vbnullString Then CountOfFilledControls = CountOfFilledControls + 1
End Select
Next oneControl
If CountOfFilledControls = [your number] Then
MsgBox "all good"
Else
MsgBox "something missing"
End IF
Private Sub UserForm_Initialize()
Me.OptionButton2 = True
Me.OptionButton4 = True
End Sub
Private Sub OptionButton1_Click
Me.Frame1.Tag = "True"
End Sub
If Me.Frame1.Tag = "True" then
Sheet1.Range("A5") = "X"' Or what ever you need to happen.
End if
I like it. Particularly this possibilityWhat I do is to put each group in it's own frame. Then in each optionbutton click event, I write that state to the Frame's Tag property.
Private Sub OptionButton1_Click
Me.Frame1.Tag = "1"
End Sub
Private Sub OptionButton2_Click
Me.Frame1.Tag = "2"
End Sub