ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running a Macro (https://www.excelbanter.com/excel-programming/297805-running-macro.html)

Keith[_11_]

Running a Macro
 
Can anybody tell me how to run a macro from a command
Button.

Excel help says to select the button then right click and
select Assign Macro from the shortcut menu, but the menu
dosn't have such an option.

I am running Excel XP

JWolf

Running a Macro
 
If you add a button using the Forms toolbar, then you can select a macro
through the shortcut menu. The macro would exist in a standard module.
The button will have a default name like Button 1.
If you add a button using the Controls Toolbox toolbar, then it has it's
own code module, available through the shortcut module. VBA associated
with this button needs to be in it's code module. The button will have
a default name like CommandButton1.

Keith wrote:

Can anybody tell me how to run a macro from a command
Button.

Excel help says to select the button then right click and
select Assign Macro from the shortcut menu, but the menu
dosn't have such an option.

I am running Excel XP


Arvi Laanemets

Running a Macro
 
Hi

There is a difference, do you use a button from Control Toolbox or Forms
Toolbar. For first, you select from dropdown menu 'View code' - an empty
OnClick event is created, and you can edit it. With another, you are asked
for procedure yo want the button to be assigned to, when you create button,
but you can assign the procedure later too. But you must have a macro
present in VBA module anyway - you can't assign non-existing macro to
command button from Forms toolbar.


--
Arvi Laanemets
(Don't use my reply address - it's spam-trap)


"Keith" wrote in message
...
Can anybody tell me how to run a macro from a command
Button.

Excel help says to select the button then right click and
select Assign Macro from the shortcut menu, but the menu
dosn't have such an option.

I am running Excel XP





All times are GMT +1. The time now is 01:19 PM.

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