Put CommandButton1 code in Module1

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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)
 
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("myButtonNameHere").delete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top