Boomshakalaka
Boomshakalaka

Reputation: 521

How to create a macro and run multiple macros consequentially?

I have an excel workbook with five different recorded macros on five different sheets. Is it possible to create another macro and run those five macros consequentially?

The difficulty is those macros are not specified to each worksheet. I have to run those macros each time manually.

Any thoughts are appreciated! Thank you.

Upvotes: 0

Views: 3919

Answers (1)

GTPV
GTPV

Reputation: 402

As explained in this question: Multithreading in VBA cannot be done natively.

Can't be done natively with VBA. VBA is built in a single-threaded apartment. The only way to get multiple threads is to build a DLL in something other than VBA that has a COM interface and call it from VBA.

So running all 5 macros at the same time would require a lot of work.

But OP mentioned in the comment that running all 5 macros sequentially would be an option.

What you can do is:

  1. Add a new module

Add a new module

  1. Add a new public sub in this module

add a new sub

  1. Reference all macro names in this sub

Example of how this macro could look like:

Public Sub allMacros()
    macroName1
    macroName2
    macroName3
    Sheet1.macroNameNotUnique
    Sheet2.macroNameNotUnique
End Sub

Now running this macro will run all the specified macros sequentially.

Upvotes: 3

Related Questions