VBA to run all checkbox code

T

Todd

I would like to create code to put on a push button that
will look at all of the check box options I have and run
the code that is assigned to each check box. The code
that is currently assigned to each checkbox is similar to
the following:
Private Sub CheckBox1_Click()
Sheets("Form").Activate
ActiveSheet.Range("AddingEquipment").Select
If Selection.Interior.Pattern = xlNone Then
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Else
With Selection.Interior
.Pattern = xlNone
End With
End If
End Sub

I would like for this code to wait until the push button
is selected to run and if other check boxes are selected
that code will run as well. Is this possible? Thanks!
 
D

Dave Peterson

There might be better ways of doing this depending on what each routine does,
but one way is to call each _click procedure:

Option Explicit
Private Sub CommandButton1_Click()
Call CheckBox1_Click
Call CheckBox2_Click
End Sub


Private Sub CheckBox1_Click()
If Me.CheckBox1.Value = False Then Exit Sub
'real code goes here
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top