Userform, checkboxes and command buttons

foxxfyre

New Member
Joined
Dec 9, 2013
Messages
8
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
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,216,228
Messages
6,129,614
Members
449,520
Latest member
TBFrieds

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top