Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default ? activate a commandbutton in code ?


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 !!!


--
tad_wegner
------------------------------------------------------------------------
tad_wegner's Profile: http://www.excelforum.com/member.php...o&userid=27770
View this thread: http://www.excelforum.com/showthread...hreadid=474762

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default ? activate a commandbutton in code ?

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.

--
Regards,
Tom Ogilvy

"tad_wegner" wrote
in message ...

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 !!!


--
tad_wegner
------------------------------------------------------------------------
tad_wegner's Profile:

http://www.excelforum.com/member.php...o&userid=27770
View this thread: http://www.excelforum.com/showthread...hreadid=474762



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Code On Activate Theresa Excel Worksheet Functions 5 December 18th 07 05:47 AM
CommandButton Code oberon.black[_58_] Excel Programming 3 September 16th 05 04:59 PM
How to activate "New" tab in Dataform through VB Code shajueasow Excel Discussion (Misc queries) 2 May 1st 05 01:15 PM
Can You Change A CommandButton Code Using A Macro? Donna[_7_] Excel Programming 4 February 11th 05 08:38 AM
Code runs different in a commandbutton than a macro why? Neal Miller Excel Programming 7 December 7th 03 02:41 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"