Macro to run Command Buttons

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
 
S

Sam Wilson

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
 
J

Jacob Skaria

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
 
R

ryguy7272

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

krcowen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top