How to assign a macro to a commnd button

G

Guest

I have created a Macro to perform the task of taking the user from one
worksheet to another upon clicking the command button. However when right
clicking on my mouse to view the short cut menu for the command button there
is no option to assign a macro to the button? The options availabl to me are
the format control at the bottom of the short cut menu. How do I activate a
Macro on a command button??
 
J

JE McGimpsey

You can assign macros in the way you want to buttons created from the
Forms toolbar. You've created a button from the Control Toolbox instead.
You can use the button's _Click() event to call your macro:

Sub CommandButton1_Click()
MyMacro
End Sub
 
G

Guest

In disign mode,right click the button then select view
code. If you have already written the macro you can use
the Call command to run it. sample code below.

Private Sub CommandButton1_Click()
Call YourMacro
End Sub
good luck
 

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