How do I create an user form to run macros in excel?

G

Guest

I want to be able to have a user form with 4 checkboxes and a submit button.
The user can choose 1 or any combination of the checkboxes. Each of the
checkboxes corresponds to a different macro. When the submit button is
clicked, only the macros that the user has chosen will execute. How do I
accomplish this? I've got the user form built; I'm just not quite sure how to
code this to get the desired result. This form will be used in Excel 2003.
Thanks.
 
G

Guest

Something along these lines:

Checkboxes are "Checkbox1","Checkbox2" .....
Macros are "macro1","macro2" ....

Private Sub CommandButton1_Click() ' "Submit button
For i = 1 To 4
If Controls("Checkbox" & i).Value Then
Run "macro" & i
End If
Next i
End Sub

HTH
 
G

Guest

Thanks for the information. Do I need to set true/false values for each of
the checkboxes?
 
G

Guest

The true/false are set when you check/uncheck the check boxes. You may want
to set them to false initially and/or after macros have been executed: the
latter to avoid inadvertently running the wrong macros if this could cause a
problem.

See the other reply re Debra's site which provides excellent examples and
guidance.
 

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