ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Put CommandButton1 code in Module1 (https://www.excelbanter.com/excel-programming/381537-put-commandbutton1-code-module1.html)

DocBrown

Put CommandButton1 code in Module1
 
Is there a way to have the command button execution code in Module1 instead
of in the worksheet. Currently the CommandButton1 code is:

Private Sub CommandButton1_Click()
ListsUpdate
End Sub

Where ListsUpdate is a macro in Module1.


Corey

Put CommandButton1 code in Module1
 
CommandButton1.Value = true

"DocBrown" wrote in message
...
Is there a way to have the command button execution code in Module1
instead
of in the worksheet. Currently the CommandButton1 code is:

Private Sub CommandButton1_Click()
ListsUpdate
End Sub

Where ListsUpdate is a macro in Module1.




Chip Pearson

Put CommandButton1 code in Module1
 
No, the event procedure code must reside in the code module of the object.
You can certainly put "ListUpdates" in Module1, but the actual click event
code must reside in the Sheet module of the sheet that contains the control.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"DocBrown" wrote in message
...
Is there a way to have the command button execution code in Module1
instead
of in the worksheet. Currently the CommandButton1 code is:

Private Sub CommandButton1_Click()
ListsUpdate
End Sub

Where ListsUpdate is a macro in Module1.




Dave Peterson

Put CommandButton1 code in Module1
 
Maybe you could delete the commandbutton (from the Control toolbox toolbar) and
use a button from the Forms toolbar.

They look pretty much the same, but you assign the macro (in a General module)
to the button (rightclick on it, choose Assign Macro).

And you could delete the Button from that sheet.

worksheets("SomeNameHere").buttons(1).delete
or by name:
worksheets("SomeNameHere").buttons("myButtonNameHe re").delete



DocBrown wrote:

Is there a way to have the command button execution code in Module1 instead
of in the worksheet. Currently the CommandButton1 code is:

Private Sub CommandButton1_Click()
ListsUpdate
End Sub

Where ListsUpdate is a macro in Module1.


--

Dave Peterson


All times are GMT +1. The time now is 05:23 PM.

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