ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Command Button & Macro (https://www.excelbanter.com/excel-programming/289470-command-button-macro.html)

alexm999[_10_]

Command Button & Macro
 
I have a macro that I'd like to somehow attach to a command button i
created in one of my cells. How do I attach a macro?


---
Message posted from http://www.ExcelForum.com/


John Wilson

Command Button & Macro
 
alexm999,

I assume that you used a command button from the "Controls Toolbox"
The "Forms" one would have asked you to assign the macro when you
created the button. You could just delete the button that you have and
use one from the "Forms" toolbar.
Or, if you want to keep the one you have.....
Right click on it.
Select "View Code"
Between the Sub and End Sub, just type in the name of your macro.

John

"alexm999 " wrote in message
...
I have a macro that I'd like to somehow attach to a command button i
created in one of my cells. How do I attach a macro?


---
Message posted from http://www.ExcelForum.com/




Ron de Bruin

Command Button & Macro
 
Hi Alex

On a button from the Forms Toolbar you can right click and assign a macro

If you have a button from the controltoolbox
Press the first button on the controltoolbox toolbar to go into the design mode
Double click on the button you placed on your worksheet.
The VBA editor will open with this

Private Sub CommandButton1_Click()

End Sub

You can place the code in the event or place the macroname in the event.
Press Alt-q to go back to Excel and press the first button on the controltoolbox again to exit the design mode



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"alexm999 " wrote in message ...
I have a macro that I'd like to somehow attach to a command button i
created in one of my cells. How do I attach a macro?


---
Message posted from http://www.ExcelForum.com/





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

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