I am trying to make a userform which pops up when a user opens my excel file. They must make a minimum of 1 selection from a list of checkboxes.
If they select checkboxes 1, 2, and/or 3, I'd like the StartJE Command Button to activate to close the Userform (and essentially take them to the first worksheet). If they don't select anything, I'd like to have that Command Button disabled. Right now, if the checkboxes are unchecked and you click StartJE, it gives you the warning msg to please make a selection, but it closes anyway and allows the user to proceed to the worksheet. I'd like to lock this down.
If they select checkbox 4, I'd like the user's only option to be to click on CloseJE Command Button which will close the spreadsheet.
This is what I have so far and thanks in advance for any guidance!
Private Sub CloseJE_Click()
ActiveWorkbook.Close
End Sub
Private Sub StartJE_Click()
Unload Me
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please make a selection."
End If
If UserForm1.CheckBox1.Value = False _
And UserForm1.CheckBox2.Value = False And UserForm1.CheckBox3.Value = False And UserForm1.CheckBox4.Value = False Then
msg = MsgBox("Please make a selection.")
End If
If UserForm1.CheckBox1.Value = False _
And UserForm1.CheckBox2.Value = False And UserForm1.CheckBox3.Value = False Then
UserForm1.StartJE.Enabled = False
Exit Sub
End If
UserForm1.StartJE.Enabled = CheckBox1.Value Or CheckBox2.Value Or CheckBox3.Value
If UserForm1.CheckBox1.Value = True Or UserForm1.CheckBox2.Value = True Or UserForm1.CheckBox3.Value = True Then
UserForm1.StartJE.Enabled = True
End If
End Sub
If they select checkboxes 1, 2, and/or 3, I'd like the StartJE Command Button to activate to close the Userform (and essentially take them to the first worksheet). If they don't select anything, I'd like to have that Command Button disabled. Right now, if the checkboxes are unchecked and you click StartJE, it gives you the warning msg to please make a selection, but it closes anyway and allows the user to proceed to the worksheet. I'd like to lock this down.
If they select checkbox 4, I'd like the user's only option to be to click on CloseJE Command Button which will close the spreadsheet.
This is what I have so far and thanks in advance for any guidance!
Private Sub CloseJE_Click()
ActiveWorkbook.Close
End Sub
Private Sub StartJE_Click()
Unload Me
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please make a selection."
End If
If UserForm1.CheckBox1.Value = False _
And UserForm1.CheckBox2.Value = False And UserForm1.CheckBox3.Value = False And UserForm1.CheckBox4.Value = False Then
msg = MsgBox("Please make a selection.")
End If
If UserForm1.CheckBox1.Value = False _
And UserForm1.CheckBox2.Value = False And UserForm1.CheckBox3.Value = False Then
UserForm1.StartJE.Enabled = False
Exit Sub
End If
UserForm1.StartJE.Enabled = CheckBox1.Value Or CheckBox2.Value Or CheckBox3.Value
If UserForm1.CheckBox1.Value = True Or UserForm1.CheckBox2.Value = True Or UserForm1.CheckBox3.Value = True Then
UserForm1.StartJE.Enabled = True
End If
End Sub
Last edited: