Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to run sub?


How to run sub from sub?

I want to run for example CommandButton1_Click() from other control
sub.


--
Boban
------------------------------------------------------------------------
Boban's Profile: http://www.excelforum.com/member.php...o&userid=28560
View this thread: http://www.excelforum.com/showthread...hreadid=482541

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to run sub?

I assume that the CommandButton_Click is an event in a worksheet?

So make it public, and call with

Call Sheet1!CommandButton1_Click

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Boban" wrote in
message ...

How to run sub from sub?

I want to run for example CommandButton1_Click() from other control
sub.


--
Boban
------------------------------------------------------------------------
Boban's Profile:

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to run sub?

From another control in the same Worksheet or userform?

Just execute it like you would any macro

Private Sub CommandButton2_Click()
CommandButton1_Click
msgbox "Executed the click event for CommandButton1"
End Sub

--
Regards,
Tom Ogilvy

"Boban" wrote in
message ...

How to run sub from sub?

I want to run for example CommandButton1_Click() from other control
sub.


--
Boban
------------------------------------------------------------------------
Boban's Profile:

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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to run sub?

Good coding practice would be to remove the code from
CommandButton1_Click and move it to a separate procedure that
could be called from anywhere.


"Boban"
wrote in message
...

How to run sub from sub?

I want to run for example CommandButton1_Click() from other
control
sub.


--
Boban
------------------------------------------------------------------------
Boban's Profile:
http://www.excelforum.com/member.php...o&userid=28560
View this thread:
http://www.excelforum.com/showthread...hreadid=482541



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



All times are GMT +1. The time now is 01:59 AM.

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

About Us

"It's about Microsoft Excel"