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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
I tried to record a macro by running the four macros but I lost information on my last excel sheet....
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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