ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Stringing Subs (https://www.excelbanter.com/excel-programming/299800-stringing-subs.html)

Randal W. Hozeski

Stringing Subs
 
I have a number of Subs:

Private Sub CommandButton1_Click()
Private Sub CommandButton2_Click()
Private Sub CommandButton3_Click()
etc.

They are pretty large.
Instead of coping the code into other Sub is
there a way to run all three at the same time?

???
Sub NewSub
Run Private Sub CommandButton1_Click()
Run Private Sub CommandButton2_Click()
Run Private Sub CommandButton3_Click()
End Sub
Does not work, any sugestions?

-Randy-






Michel Pierron[_2_]

Stringing Subs
 
Hi Randy,

Sub NewSub
CommandButton1_Click
CommandButton2_Click
CommandButton3_Click
End Sub

MP

"Randal W. Hozeski" a écrit dans le message de
...
I have a number of Subs:

Private Sub CommandButton1_Click()
Private Sub CommandButton2_Click()
Private Sub CommandButton3_Click()
etc.

They are pretty large.
Instead of coping the code into other Sub is
there a way to run all three at the same time?

???
Sub NewSub
Run Private Sub CommandButton1_Click()
Run Private Sub CommandButton2_Click()
Run Private Sub CommandButton3_Click()
End Sub
Does not work, any sugestions?

-Randy-








Tom Ogilvy

Stringing Subs
 
In the sheet module, declare them as Public
Public Sub CommandButton1_Click()
MsgBox "#1"
End Sub

Public Sub CommandButton2_Click()
MsgBox "#2"
End Sub

Public Sub CommandButton3_Click()
MsgBox "#3"
End Sub

then in a general module

Sub RunAll()
Sheet1.CommandButton1_Click
Sheet1.CommandButton2_Click
Sheet1.CommandButton3_Click
End Sub

or

Sub RunAll()
Application.Run "Sheet1.CommandButton1_click"
Application.Run "Sheet1.CommandButton2_click"
Application.Run "Sheet1.CommandButton3_Click"
End Sub

Both worked for me.

--
Regards,
Tom Ogilvy



"Randal W. Hozeski" wrote in message
...
I have a number of Subs:

Private Sub CommandButton1_Click()
Private Sub CommandButton2_Click()
Private Sub CommandButton3_Click()
etc.

They are pretty large.
Instead of coping the code into other Sub is
there a way to run all three at the same time?

???
Sub NewSub
Run Private Sub CommandButton1_Click()
Run Private Sub CommandButton2_Click()
Run Private Sub CommandButton3_Click()
End Sub
Does not work, any sugestions?

-Randy-









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

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