ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Control button / macro (https://www.excelbanter.com/excel-discussion-misc-queries/130185-control-button-macro.html)

Sarah

Control button / macro
 
Hi there,
I have a control button on a spreadsheet. And I have a macro already
written. How do I attach that macro to the button without having to write or
copy the macro code into the control code? I'm really bad at writing that
stuff and I think I am messing up the syntax so wondered if there was an
easier way.
Thanks!

[email protected]

Control button / macro
 
Le'ts assume your macro is named "myFavoriteMacro" and you want to do
things very, very simply.
On your worksheet, double-click the control button. This will pop-up
the VBE environment with some code pointing to your command button. It
will look something like:
Private Sub CommandButton1_Click()

End Sub
All you need to do is put in the line "Call myFavoriteMacro" before
the "End Sub" and you're there.

HTH
/ Tyla /

On Feb 10, 5:57 pm, Sarah wrote:
Hi there,
I have a control button on a spreadsheet. And I have a macro already
written. How do I attach that macro to the button without having to write or
copy the macro code into the control code? I'm really bad at writing that
stuff and I think I am messing up the syntax so wondered if there was an
easier way.
Thanks!




Gord Dibben

Control button / macro
 
You could, as a possible alternative, create your button from the Forms toolbar.

Right-click and "assign macro".

Select your macro by name and OK.


Gord Dibben MS Excel MVP

On Sat, 10 Feb 2007 17:57:00 -0800, Sarah
wrote:

Hi there,
I have a control button on a spreadsheet. And I have a macro already
written. How do I attach that macro to the button without having to write or
copy the macro code into the control code? I'm really bad at writing that
stuff and I think I am messing up the syntax so wondered if there was an
easier way.
Thanks!




All times are GMT +1. The time now is 12:44 PM.

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