? activate a commandbutton in code ?

T

tad_wegner

does anybody know how to activate a commandbutton in a macro?

(there is no way around me having to do this... i need to batch a very
poorly organized workbook, and i have to go through a commandbutton to
do so)

to activate the commandbutton normally you just "click" it with the
mouse. but i cant figure out how to do it in a macro. i want to
automate this workbook so i can run this program multiple times. ive
tried dozens of different lines and none work. ive also tried recording
a macro to show me the correct code but the recorder stops when you try
to do this.

!!! PLEASE - SOMEONE HELP !!!
 
T

Tom Ogilvy

Change the click event from Private to public, then you just call the event
in your code.

Private Sub Commandbutton1_Click()
changed to
Public Sub Commandbutton1_Click()

then call it with

Sheet1!CommandButton1_Click'

where Sheet1 is the code name of the sheet containing the code.
 

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

Top