AwesomeSteph
Board Regular
- Joined
- Aug 18, 2017
- Messages
- 80
I have a userform that I would like to reopen after an error pops up if option buttons aren't selected within frames.
I have a code that works for the error but once the error is closed the userform is also closed. I need the user to be forced to make a selection from both frames in the userform.
I have a code that works for the error but once the error is closed the userform is also closed. I need the user to be forced to make a selection from both frames in the userform.
Code:
Private Sub CommandButton1_Click()
Unload Me
If OptionButton1.Value = True Then
Sheet8.CheckBox1.Value = False
Sheet7.Visible = True
End If
If OptionButton2.Value = True Then
Sheet8.CheckBox1.Value = True
Sheet7.Visible = False
End If
If OptionButton3.Value = True Then
Sheet8.CheckBox2.Value = False
Sheet7.Visible = True
End If
If OptionButton4.Value = True Then
Sheet8.CheckBox2.Value = True
Sheet7.Visible = False
End If
For Each ctrl In Frame1.Controls
If TypeOf ctrl Is msforms.OptionButton Then
If ctrl.Value = True Then
F1D = True
Exit For
End If
End If
Next ctrl
If F1D = False Then
MsgBox "No Option Selected In Frame 1"
End If
For Each ctrl In Frame2.Controls
If TypeOf ctrl Is msforms.OptionButton Then
If ctrl.Value = True Then
F2D = True
Exit For
End If
End If
Next ctrl
If F2D = False Then
MsgBox "No Option Selected In Frame 2"
End If
End Sub