ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Assigning a macro to a command button (https://www.excelbanter.com/excel-discussion-misc-queries/111433-assigning-macro-command-button.html)

SheriTingle

Assigning a macro to a command button
 
I posted this question earlier today but I forgot to mention an important
item. The right click, assign macro choice is not available with the button I
used (the command button on the control toolbox.) Here's the earlier post.

I accidently used the wrong button and am hoping there is a fix. I need to
run a macro from a button.

I know that if I use the button (control button) from the forms toolbar the
first thing it asks me to do is to assign a macro and all would work fine.
But...

I used the command button from the control toolbox to make the buttons (I
made many of them and would prefer not to remake them). I would like to run a
macro from each of these buttons and now I can't figure out how to attach the
macro to the buttons I've already made. The buttons came from the command
button on the control toolbox.

Is there a way to attach a macro to these buttons?? THANKS !


CLR

Assigning a macro to a command button
 
Macros are "assigned" to those buttons in the SheetModule.........here's a
typical example........

Private Sub CommandButton1_Click()
Call YourMacroName
Sheets("Notes").Select
Application.Goto Reference:="R500C1"
Application.Goto Reference:="R72C1"
MsgBox "Hey!....you just pushed my button!"
End Sub


hth
Vaya con Dios,
Chuck, CABGx3


"SheriTingle" wrote:

I posted this question earlier today but I forgot to mention an important
item. The right click, assign macro choice is not available with the button I
used (the command button on the control toolbox.) Here's the earlier post.

I accidently used the wrong button and am hoping there is a fix. I need to
run a macro from a button.

I know that if I use the button (control button) from the forms toolbar the
first thing it asks me to do is to assign a macro and all would work fine.
But...

I used the command button from the control toolbox to make the buttons (I
made many of them and would prefer not to remake them). I would like to run a
macro from each of these buttons and now I can't figure out how to attach the
macro to the buttons I've already made. The buttons came from the command
button on the control toolbox.

Is there a way to attach a macro to these buttons?? THANKS !



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

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