Checkboxes problem

butler.n

New Member
Joined
Oct 13, 2006
Messages
20
Hi

Iv got a sheet where i have a bunch on check boxes. These check boxes relate to an overall check box indicating that all of the actions have been complete.
Does anyone know a VB code on how this check box can show ticked when all of the action check boxes have been ticked

Many Thanks
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
You mentioned a 'bunch' of checkboxes. In my little bit of code I only have three. You may need to modify to add the extra checkboxes or see if someone can do the same job with a loop.

Basically, my code calls for a sub procedure(BOXCHECK) whenever one of the action check boxes have been ticked.

Private Sub CheckBox2_Click()
BOXCHECK
End Sub

Private Sub CheckBox3_Click()
BOXCHECK
End Sub

Private Sub CheckBox4_Click()
BOXCHECK
End Sub


Public Sub BOXCHECK()
If CheckBox2.Value = True And CheckBox3.Value = True And CheckBox4.Value = True Then
CheckBox1.Value = True
Else
If CheckBox2.Value = False Then CheckBox1.Value = False
If CheckBox3.Value = False Then CheckBox1.Value = False
If CheckBox4.Value = False Then CheckBox1.Value = False
End If
End Sub
 
Upvote 0
There should be a better way to do this with a class module, but just don't have time to whip it up... taking Marc's as a starting point here's a way to make the "all" checkbox also work as a "controlling toggle" where, if you check it or uncheck it, all the "slave" checkboxes follow suit...
Code:
Private m_booStopChain As Boolean

Private Sub CheckBox1_Click()
    If Not m_booStopChain Then AreAllChecked
End Sub

Private Sub CheckBox2_Click()
    If Not m_booStopChain Then AreAllChecked
End Sub

Private Sub CheckBox3_Click()
    If Not m_booStopChain Then AreAllChecked
End Sub

Private Sub CheckBoxAll_Click()
    If Not m_booStopChain Then
        m_booStopChain = True
        With Me
            .CheckBox1 = .CheckBoxAll
            .CheckBox2 = .CheckBoxAll
            .CheckBox3 = .CheckBoxAll
        End With
    End If
    m_booStopChain = False
End Sub

Private Sub AreAllChecked()
    m_booStopChain = True
    With Me
        .CheckBoxAll = (.CheckBox1 And .CheckBox2 And .CheckBox3)
    End With
    m_booStopChain = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,465
Members
448,965
Latest member
grijken

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