ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Command buttons & macros (https://www.excelbanter.com/excel-discussion-misc-queries/14201-command-buttons-macros.html)

Jock W

Command buttons & macros
 
How do I allocate a macro to a command button?
Right clicking a command button which is in design mode brings down a drop
down menu but 'assign macro' isn't on option.
--
Jock Waddington

Bob Phillips

Jock,

Sounds like you have control toolbox button.. Assuming so, when in design
mode, double-click the button, and then will open up the worksheet code
module, and create a skeleton click event which would be where you add your
code.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jock W" wrote in message
...
How do I allocate a macro to a command button?
Right clicking a command button which is in design mode brings down a drop
down menu but 'assign macro' isn't on option.
--
Jock Waddington




Earl Kiosterud

Jock,

Command buttons have their own event handlers. Double-clicking one will
take you to it, something like:

Private Sub CommandButton1_Click()
' you could call your macro in here
' or just put the code here
End Sub

This event handler lives in the sheet module, like worksheet_change and
other events.
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Jock W" wrote in message
...
How do I allocate a macro to a command button?
Right clicking a command button which is in design mode brings down a drop
down menu but 'assign macro' isn't on option.
--
Jock Waddington




Jock W

Thanks to Bob and Earl. Job done

"Earl Kiosterud" wrote:

Jock,

Command buttons have their own event handlers. Double-clicking one will
take you to it, something like:

Private Sub CommandButton1_Click()
' you could call your macro in here
' or just put the code here
End Sub

This event handler lives in the sheet module, like worksheet_change and
other events.
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Jock W" wrote in message
...
How do I allocate a macro to a command button?
Right clicking a command button which is in design mode brings down a drop
down menu but 'assign macro' isn't on option.
--
Jock Waddington






All times are GMT +1. The time now is 06:59 PM.

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