1
votes

I am working on an analysis template with a UserForm.
I have macros associated with checkboxes. I want to activate them by clicking the separate analysis command box. The macros are called: graph_dur, graph_ram, dur_calc, ram_calc.

The UserForm allows users to check off the analyses they want, then run calculations with an "Analysis" command button.

enter image description here

Any boxes that are not checked should not run their macros when "Analyze" is clicked.

I understand that when a checkbox is "checked" then it returns "True".
I don't know how to associate the True return with the run of a macro when "Analyze" is activated.

This code is not correct, but attempts to highlight my basic layout.

Private Sub CheckBox1_Click() 
    If CheckBox1 = True
        Then Call.Graph_duration
    Else CheckBox1 = False
    End If 
End Sub

Private Sub CheckBox2_Click()
    If CheckBox2 = True
        Then Call.Graph_ram
        Else CheckBox2 = False
    End If
End Sub
1
What do you mean by "seperate analysis command box"?SJR
Try using CheckBox1.Value =True, however on the way you are making the code, you already call the functions, normally you would create a button that checks all the Checkboxes and then call the functionsdanieltakeshi
Sorry, Bad wording on my part. In the picture attached, there is a command button called Analyze. It is this button that should be activated to run the macros associated with the checked off boxes.Skrelly Joe
Thats a good point dantakeshi, its gets to the root of my question. That is, how do you recognize which boxes have been selected by the user, then run only those "checked" macros. There are some macros that will go un-used because certain users might not need them for there analyses.Skrelly Joe

1 Answers

0
votes

Perhaps you mean something like this - it should be attached to your button. If you had lots of checkboxes then this will become inefficient.

Private Button_Click()

    If CheckBox1 Then
        Graph_Duration
    End If

    If CheckBox2 Then
        Graph_ram
    End If
    'etc

End Sub