Check Box - Forced Validation

austin350s10

Active Member
Joined
Jul 30, 2010
Messages
321
I have a form I am working on that has multiple series of check boxes. Each series contains 4 check boxes.

Example:
Series 1
Check box 1 value associated = 1
Check box 2 value associated = 2
Check box 3 value associated = 3
Check box 4 value associated = 4

Series 2
Check box 1 value associated = 1
Check box 2 value associated = 2
Check box 3 value associated = 3
Check box 4 value associated = 4

PROBLEM: For the form to work properly the user can only check 1 of the 4 check boxes in the current series. However with my novice experience in excel I can't seem to force excel to allow only 1 of the 4 check boxes to be check at any given time.

QUESTION: Is there a solution that would apply to all the series of check boxes without having to use Option Buttons?

NOTE: The user also needs to have the option of not checking any of the boxes in a series.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi austin350s10

Try this
Code:
Private Sub CheckBox1_Click()
    If CheckBox1.Value = True Then
       CheckBox2.Value = False
       CheckBox3.Value = False
       CheckBox4.Value = False
    Else: End If
End Sub
Private Sub CheckBox2_Click()
    If CheckBox2.Value = True Then
       CheckBox1.Value = False
       CheckBox3.Value = False
       CheckBox4.Value = False
    Else: End If
End Sub
Private Sub CheckBox3_Click()
    If CheckBox3.Value = True Then
       CheckBox1.Value = False
       CheckBox2.Value = False
       CheckBox4.Value = False
    Else: End If
End Sub
Private Sub CheckBox4_Click()
    If CheckBox4.Value = True Then
       CheckBox1.Value = False
       CheckBox2.Value = False
       CheckBox3.Value = False
    Else: End If
End Sub

For Series 2 use CheckBox5, CheckBox6, CheckBox7, CheckBox8
 
Last edited:
Upvote 0
Include each series of checkbox and a frame and modify the following code


Code:
Sub chk(cb As MSForms.CheckBox)
If cb = False Then Exit Sub
Dim i As MSForms.CheckBox
For Each i In Me.Frame1.Controls
    i = False
Next
 cb = True
End Sub
Private Sub CheckBox1_Click()
    Call chk(CheckBox1)
End Sub
Private Sub CheckBox4_Click()
    Call chk(CheckBox4)
End Sub
Private Sub CheckBox2_Click()
Call chk(CheckBox2)
End Sub
Private Sub CheckBox3_Click()
Call chk(CheckBox3)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,582
Members
449,089
Latest member
Motoracer88

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