Macro to run Command Buttons

  • Thread starter Thread starter Leigh Douglass
  • Start date Start date
L

Leigh Douglass

Hi

I have 13 individual macros assigned to 13 individual command buttons on 13
separate sheets. I would like one more command button with a macro that runs
all of the other 13 macros/buttons.

thanks
Leigh
 
create the following procedure in a module:

sub RunAllMacros

call Macro1
call Macro2
....
call Macro 13

end sub

create the new command button and assign the macro "RunAllMacros" to it.

Sam
 
Just to add on.... please make sure sheets are refered properly within your
macro like Sheets("Sheename"). and not as ActiveSheet. or ActiveCell.

If this post helps click Yes
 
You will need to insert a Call at the end of each sub.
Like this:
Call mysub()

Remember, VBA executes in linear fashion, so call the second sub from the
first, call the third sub from the second, etc.

HTH,
Ryan---
 
Leigh

Something like the following in the code module for the sheet with the
button that runs all 13 should work:

Option Explicit

Private Sub CommandButton1_Click()
MsgBox "test 1"
End Sub

Private Sub CommandButton3_Click()
Call CommandButton1_Click
Call Sheet2.CommandButton1_Click
Call Sheet3.CommandButton1_Click
End Sub

You need to make sure the commond button procedures on the sheets
other than the calling sheet are not Private.

Good luck.

Ken
Norfolk, Va
 
Back
Top