Click once

Sheree

New Member
Joined
Jan 13, 2005
Messages
24
Hi Guys,

I would like to click once and 5 macros go into action, how do I do this?

I can't put the macros together because they don't run the way I like.

Sheree
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
You can use something like this:

<font face=Tahoma><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> CommandButton1_Click()
    <SPAN style="color:#00007F">With</SPAN> Application
        .Run "Macro1"
        .Run "Macro2"
        .Run "Macro3"
        .Run "Macro4"
        .Run "Macro5"
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,

Smitty
 

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,460
Add in this macro (which is the one you will attach to the button)

Sub Run Macros()
MacroOne
MacroTwo
End sub

Sub MacroOne()
[Your macro here]
End Sub

etc

In other words, just type in the names of the macros. When it exits macro1 it will return to this sub and run macro 2.

It is an effective way of writing macros (separate into its parts) as it makes it easier to modify or remove parts later.
 

cstlaurent

Board Regular
Joined
Jan 14, 2005
Messages
182
create five buton, assign a macro to each ot them. and record a macro clicking on it.

Or use VBA

docmd.runmacro "1"
docmd.runmacro "2"

and so. ans so
 

Sheree

New Member
Joined
Jan 13, 2005
Messages
24

ADVERTISEMENT

I just tried that way and all the macros worked on one page of my doc,I need the macros to run on different sheets with in a the doc.
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
How about:

<font face=Tahoma><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> CommandButton1_Click()
    Application.Run "Macro1"
        Sheets("Sheet2").Activate
    Application.Run "Macro2"
        Sheets("Sheet3").Activate
    Application.Run "Macro3"
        Sheets("Sheet4").Activate
    Application.Run "Macro4"
        Sheets("Sheet5").Activate
    Application.Run "Macro5"
        Sheets("Sheet6").Activate
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>

Smitty
 

Sheree

New Member
Joined
Jan 13, 2005
Messages
24

ADVERTISEMENT

I tried to record a macro by running the four macros but I lost information on my last excel sheet....
 

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,460
Or add into your macros:
For each Worksheet in Workbook....
 

Forum statistics

Threads
1,147,847
Messages
5,743,522
Members
423,801
Latest member
paulj4177

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top