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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Sahak

Well-known Member
Joined
Nov 10, 2006
Messages
980
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
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:

Fowmy

Well-known Member
Joined
Jul 10, 2008
Messages
512
Office Version
  1. 365
Platform
  1. Windows
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,109
Messages
5,857,441
Members
431,879
Latest member
KiwDaWabbit

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
Top