Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Assigning a macro to a button

  Asked By: Zobah    Date: Nov 30    Category: MS Office    Views: 1014
  

I have created a macro. I have also created a button. When I right
click on the button I do not have the option to assign the macro to
the button. I know this is very basic but I seemed to have forgotten
the basics.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Roderick King     Answered On: Nov 30

I was unable to
create a command button  that didn't have that option  on the right-click
menu, so I'm not sure what happened to you there.

However, you can assign  the macro  to the button using code. Go into the VBA
editor (Alt and F11). Insert a module by right clicking on your worksheet
and choosing, insert, then module. Add the following lines of code:

Sub Button1_Click()
Macro1
End Sub

Just change the Button1 to be the name of your button, and change the Macro1
to be the name of your macro.

 
Answer #2    Answered By: Fatih Farooq     Answered On: Nov 30

you must be created  a button  using control toolbox. If that what happen,
yes you can add macro  using codes suggested by Salina. But you can create
button using Forms (just customise your toolbar to include forms), this
will directly ask you to insert macro.

 
Didn't find what you were looking for? Find more on Assigning a macro to a button Or get search suggestion and latest updates.




Tagged: