ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to run sub? (https://www.excelbanter.com/excel-programming/344829-how-run-sub.html)

Boban[_4_]

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


Bob Phillips[_6_]

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




Tom Ogilvy

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




Chip Pearson

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





All times are GMT +1. The time now is 09:32 AM.

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