Stringing Subs

R

Randal W. Hozeski

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

Michel Pierron

Hi Randy,

Sub NewSub
CommandButton1_Click
CommandButton2_Click
CommandButton3_Click
End Sub

MP
 
T

Tom Ogilvy

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.
 
Top