VBA to select two checkboxes

Wills1971

New Member
Joined
Mar 7, 2013
Messages
11
Hi All,
I would like to select two checkboxes and run a macro, e.g. I have two checkboxes 1 call ChkBoxCarrA & a 2nd called ChkBoxCarrB. If I only select ChkBoxCarrA it calls a macro to produce a graph, If I only select ChkBoxCarrB it calls a different macro to produce a graph.

I want to be able to select both ChkBoxCarrA & ChkBoxCarrB to call a macro to display both graphs at the same time. It works ok as long as there is only 1 Checkbox selected. But not when I have both Checkboxes selected.

I tried to do this using the following code

Code:
Private Sub CmdDisplayGraph_Click()
    'LA5
    If OptGrapLa5.Value = "True" And ChkBoxCarrA.Value = "True" Then
        Call LA5Backlash.LA5lashA
        
    ElseIf OptGrapLa5.Value = "True" And ChkBoxCarrB.Value = "True" Then
        Call LA5Backlash.LA5lashB
        
    ElseIf OptGrapLa5.Value = "True" And ChkBoxCarrA.Value = "True" And ChkBoxCarrB.Value = "True" Then
        Call LA5Backlash.LA5lashAB
        
    End If
   
End Sub

But when it tries to run the line below when both Checkboxes are selected

Code:
ElseIf OptGrapLa5.Value = "True" And ChkBoxCarrA.Value = "True" And ChkBoxCarrB.Value = "True" Then
        Call LA5Backlash.LA5lashAB

it sees the ChkBoxCarrA and runs it's macro then finishes and doesn't see the rest of the statement.

Any help is greatly appreciated,

Will
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,224,817
Messages
6,181,148
Members
453,021
Latest member
Justyna P

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