tick only one checkbox

emilemil22

New Member
Joined
Aug 18, 2019
Messages
27
Hi there,
I am making a userform. I have to checkboxes, checkbox1 and checkbox2. I want to make it such that user can only check one of them at tiime.

And I also want to make it as mandatory question for the user such that he or she needs to tick one of the checkboxes!

thanks for your help
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
For those cases it is best to create 2 OptionButton.


You put the following code on your button to verify:

Code:
Private Sub CommandButton1_Click()
  If OptionButton1 = False And OptionButton2 = False Then
    MsgBox "You must select an option."
  End If
End Sub

Example:

6e1cf39bf97f52c1b94d2096e069c8b3.jpg
 
Upvote 0
Thanks a lot for your reply. I will amend tge checkboxes into option buttons.

Also I want to make it such that whenever the user ticks option button 2 then everything already entered in textbox1, textbox 2, listbox1 and listbox 2is automatically deleted.

Is it possible to do that?
 
Upvote 0
Try this

Code:
Private Sub OptionButton2_Click()
  If OptionButton2 = True Then
    TextBox1 = ""
    TextBox2 = ""
    ListBox1.Clear
    ListBox2.Clear
  End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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