![]() |
in vb, what is the 1-line code of assigning a macro using click
I am looking for a sample of the syntax where the macro name and click are on
the vb line. |
in vb, what is the 1-line code of assigning a macro using click
For a control from the forms toolbar:
Activesheet.Buttons(1).OnAction = "MyMacro" -- Regards, Tom Ogilvy "ExcelSuperUser" wrote: I am looking for a sample of the syntax where the macro name and click are on the vb line. |
in vb, what is the 1-line code of assigning a macro using clic
sorry, not what i was looking for. let me give you more info. i set up a
command button in excel and would like to assign the macro to the button. if i right click, assign macro is not listed (not sure why) but if i go to the vb editor, i would like to type a line in that assigns the macro to the button. i seem to recall that it would have the button object, macro name and click on one line. i also recall that it is very simple and a basic statement. "Tom Ogilvy" wrote: For a control from the forms toolbar: Activesheet.Buttons(1).OnAction = "MyMacro" -- Regards, Tom Ogilvy "ExcelSuperUser" wrote: I am looking for a sample of the syntax where the macro name and click are on the vb line. |
in vb, what is the 1-line code of assigning a macro using clic
I gave you the code to assign a macro to a button from the forms toolbar.
However, Command buttons from the control toolbox toolbar are not assigned to macros. They have build in events. To get to the Click event for the Commandbutton, right click on the sheet tab that contains the button and select view code. In the resulting sheet module, at the top of the module, in the left dropdown select Commandbutton1 (or the name of your command button) and in the right dropdown select Click. YOu will get the event Private Sub CommandButton1_Click() End sub You can put your code in this procedure/event. (including a call to a macro in a general module). -- regards, Tom Ogilvy "ExcelSuperUser" wrote: sorry, not what i was looking for. let me give you more info. i set up a command button in excel and would like to assign the macro to the button. if i right click, assign macro is not listed (not sure why) but if i go to the vb editor, i would like to type a line in that assigns the macro to the button. i seem to recall that it would have the button object, macro name and click on one line. i also recall that it is very simple and a basic statement. "Tom Ogilvy" wrote: For a control from the forms toolbar: Activesheet.Buttons(1).OnAction = "MyMacro" -- Regards, Tom Ogilvy "ExcelSuperUser" wrote: I am looking for a sample of the syntax where the macro name and click are on the vb line. |
All times are GMT +1. The time now is 11:39 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com