ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   assigning macro to button (https://www.excelbanter.com/excel-discussion-misc-queries/44868-assigning-macro-button.html)

BorisS

assigning macro to button
 
In versions before 03, I remember there was a way to simply assign a macro to
a button that was created. Now I cannot tell how to do it. I have used the
control toolbar to create the toolbar and I have a macro, but I don't know
how to assign it.
--
Boris

Rowan

When you create the button from the Controls Toolbox it will be in
design mode. Double clicking it should take you to the default event for
the button i.e. the sheet module for the relevant worksheet with code eg:

Private Sub CommandButton1_Click()

End Sub

Change this to

Private Sub CommandButton1_Click()
Call MyMacro 'your macro name
End Sub

Alternately, use a button from the Forms Toolbar. Right click the button
and select Assign Macro.

Hope this helps.
Rowan

BorisS wrote:
In versions before 03, I remember there was a way to simply assign a macro to
a button that was created. Now I cannot tell how to do it. I have used the
control toolbar to create the toolbar and I have a macro, but I don't know
how to assign it.


BorisS

thanks. I forgot it was the forms toolbar that let me make the button I
wanted.
--
Boris


"Rowan" wrote:

When you create the button from the Controls Toolbox it will be in
design mode. Double clicking it should take you to the default event for
the button i.e. the sheet module for the relevant worksheet with code eg:

Private Sub CommandButton1_Click()

End Sub

Change this to

Private Sub CommandButton1_Click()
Call MyMacro 'your macro name
End Sub

Alternately, use a button from the Forms Toolbar. Right click the button
and select Assign Macro.

Hope this helps.
Rowan

BorisS wrote:
In versions before 03, I remember there was a way to simply assign a macro to
a button that was created. Now I cannot tell how to do it. I have used the
control toolbar to create the toolbar and I have a macro, but I don't know
how to assign it.




All times are GMT +1. The time now is 05:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com