How to create a macro and run multiple macros consequentially?










-1















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.










share|improve this question



















  • 1





    By "at the same time" do you mean that they HAVE to run concurrently or is it ok if the macro run sequentially?

    – GTPV
    Nov 13 '18 at 15:11











  • Because concurrently isn't, strictly speaking, possible with single-threaded vba...

    – Mistella
    Nov 13 '18 at 15:12






  • 1





    It would be easier to have the five different macros in a normal module that reference the five sheets and call them from there.

    – Darren Bartrup-Cook
    Nov 13 '18 at 15:12











  • Hi @GTPV, consequentially works for me.

    – Boomshakalaka
    Nov 13 '18 at 15:13











  • @Darren Bartrup-Cook, because I recorded those macros for formats, the codes are really big.

    – Boomshakalaka
    Nov 13 '18 at 15:15















-1















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.










share|improve this question



















  • 1





    By "at the same time" do you mean that they HAVE to run concurrently or is it ok if the macro run sequentially?

    – GTPV
    Nov 13 '18 at 15:11











  • Because concurrently isn't, strictly speaking, possible with single-threaded vba...

    – Mistella
    Nov 13 '18 at 15:12






  • 1





    It would be easier to have the five different macros in a normal module that reference the five sheets and call them from there.

    – Darren Bartrup-Cook
    Nov 13 '18 at 15:12











  • Hi @GTPV, consequentially works for me.

    – Boomshakalaka
    Nov 13 '18 at 15:13











  • @Darren Bartrup-Cook, because I recorded those macros for formats, the codes are really big.

    – Boomshakalaka
    Nov 13 '18 at 15:15













-1












-1








-1








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.










share|improve this question
















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.







excel vba excel-vba excel-2010 record






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 8:15









Pᴇʜ

21.1k42750




21.1k42750










asked Nov 13 '18 at 15:09









BoomshakalakaBoomshakalaka

807




807







  • 1





    By "at the same time" do you mean that they HAVE to run concurrently or is it ok if the macro run sequentially?

    – GTPV
    Nov 13 '18 at 15:11











  • Because concurrently isn't, strictly speaking, possible with single-threaded vba...

    – Mistella
    Nov 13 '18 at 15:12






  • 1





    It would be easier to have the five different macros in a normal module that reference the five sheets and call them from there.

    – Darren Bartrup-Cook
    Nov 13 '18 at 15:12











  • Hi @GTPV, consequentially works for me.

    – Boomshakalaka
    Nov 13 '18 at 15:13











  • @Darren Bartrup-Cook, because I recorded those macros for formats, the codes are really big.

    – Boomshakalaka
    Nov 13 '18 at 15:15












  • 1





    By "at the same time" do you mean that they HAVE to run concurrently or is it ok if the macro run sequentially?

    – GTPV
    Nov 13 '18 at 15:11











  • Because concurrently isn't, strictly speaking, possible with single-threaded vba...

    – Mistella
    Nov 13 '18 at 15:12






  • 1





    It would be easier to have the five different macros in a normal module that reference the five sheets and call them from there.

    – Darren Bartrup-Cook
    Nov 13 '18 at 15:12











  • Hi @GTPV, consequentially works for me.

    – Boomshakalaka
    Nov 13 '18 at 15:13











  • @Darren Bartrup-Cook, because I recorded those macros for formats, the codes are really big.

    – Boomshakalaka
    Nov 13 '18 at 15:15







1




1





By "at the same time" do you mean that they HAVE to run concurrently or is it ok if the macro run sequentially?

– GTPV
Nov 13 '18 at 15:11





By "at the same time" do you mean that they HAVE to run concurrently or is it ok if the macro run sequentially?

– GTPV
Nov 13 '18 at 15:11













Because concurrently isn't, strictly speaking, possible with single-threaded vba...

– Mistella
Nov 13 '18 at 15:12





Because concurrently isn't, strictly speaking, possible with single-threaded vba...

– Mistella
Nov 13 '18 at 15:12




1




1





It would be easier to have the five different macros in a normal module that reference the five sheets and call them from there.

– Darren Bartrup-Cook
Nov 13 '18 at 15:12





It would be easier to have the five different macros in a normal module that reference the five sheets and call them from there.

– Darren Bartrup-Cook
Nov 13 '18 at 15:12













Hi @GTPV, consequentially works for me.

– Boomshakalaka
Nov 13 '18 at 15:13





Hi @GTPV, consequentially works for me.

– Boomshakalaka
Nov 13 '18 at 15:13













@Darren Bartrup-Cook, because I recorded those macros for formats, the codes are really big.

– Boomshakalaka
Nov 13 '18 at 15:15





@Darren Bartrup-Cook, because I recorded those macros for formats, the codes are really big.

– Boomshakalaka
Nov 13 '18 at 15:15












1 Answer
1






active

oldest

votes


















3














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.






share|improve this answer























  • Thank you so much. The answer helps me!

    – Boomshakalaka
    Nov 13 '18 at 17:28











  • You know, I'd assumed the macros were in Worksheet modules which are Private so this way wouldn't work - but OP recorded the macros which automatically puts them in normal modules... I should read the questions more thoroughly.

    – Darren Bartrup-Cook
    Nov 13 '18 at 17:29











  • Hi@GTPV, I am a little confused about Sheet1.macroNameNotUnique What should be the input for "macroNameNotUnique"?

    – Boomshakalaka
    Nov 13 '18 at 19:26











  • @Boomshakalaka glad I could help. If your macros require no input then there should be no input when you call the macros. If some of your macros do not have a unique name then you first need to specify the name of the module where the macro is located. For instance: "module1.macroNameNotUnique". Finally, if your macro requires an input then you just add it after. For example: "uniqueMacroName input1, input2, inputN"

    – GTPV
    Nov 14 '18 at 14:33











  • @GTPV Thanks for the reply

    – Boomshakalaka
    Nov 15 '18 at 22:34











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283956%2fhow-to-create-a-macro-and-run-multiple-macros-consequentially%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














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.






share|improve this answer























  • Thank you so much. The answer helps me!

    – Boomshakalaka
    Nov 13 '18 at 17:28











  • You know, I'd assumed the macros were in Worksheet modules which are Private so this way wouldn't work - but OP recorded the macros which automatically puts them in normal modules... I should read the questions more thoroughly.

    – Darren Bartrup-Cook
    Nov 13 '18 at 17:29











  • Hi@GTPV, I am a little confused about Sheet1.macroNameNotUnique What should be the input for "macroNameNotUnique"?

    – Boomshakalaka
    Nov 13 '18 at 19:26











  • @Boomshakalaka glad I could help. If your macros require no input then there should be no input when you call the macros. If some of your macros do not have a unique name then you first need to specify the name of the module where the macro is located. For instance: "module1.macroNameNotUnique". Finally, if your macro requires an input then you just add it after. For example: "uniqueMacroName input1, input2, inputN"

    – GTPV
    Nov 14 '18 at 14:33











  • @GTPV Thanks for the reply

    – Boomshakalaka
    Nov 15 '18 at 22:34
















3














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.






share|improve this answer























  • Thank you so much. The answer helps me!

    – Boomshakalaka
    Nov 13 '18 at 17:28











  • You know, I'd assumed the macros were in Worksheet modules which are Private so this way wouldn't work - but OP recorded the macros which automatically puts them in normal modules... I should read the questions more thoroughly.

    – Darren Bartrup-Cook
    Nov 13 '18 at 17:29











  • Hi@GTPV, I am a little confused about Sheet1.macroNameNotUnique What should be the input for "macroNameNotUnique"?

    – Boomshakalaka
    Nov 13 '18 at 19:26











  • @Boomshakalaka glad I could help. If your macros require no input then there should be no input when you call the macros. If some of your macros do not have a unique name then you first need to specify the name of the module where the macro is located. For instance: "module1.macroNameNotUnique". Finally, if your macro requires an input then you just add it after. For example: "uniqueMacroName input1, input2, inputN"

    – GTPV
    Nov 14 '18 at 14:33











  • @GTPV Thanks for the reply

    – Boomshakalaka
    Nov 15 '18 at 22:34














3












3








3







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 15:36









GTPVGTPV

1464




1464












  • Thank you so much. The answer helps me!

    – Boomshakalaka
    Nov 13 '18 at 17:28











  • You know, I'd assumed the macros were in Worksheet modules which are Private so this way wouldn't work - but OP recorded the macros which automatically puts them in normal modules... I should read the questions more thoroughly.

    – Darren Bartrup-Cook
    Nov 13 '18 at 17:29











  • Hi@GTPV, I am a little confused about Sheet1.macroNameNotUnique What should be the input for "macroNameNotUnique"?

    – Boomshakalaka
    Nov 13 '18 at 19:26











  • @Boomshakalaka glad I could help. If your macros require no input then there should be no input when you call the macros. If some of your macros do not have a unique name then you first need to specify the name of the module where the macro is located. For instance: "module1.macroNameNotUnique". Finally, if your macro requires an input then you just add it after. For example: "uniqueMacroName input1, input2, inputN"

    – GTPV
    Nov 14 '18 at 14:33











  • @GTPV Thanks for the reply

    – Boomshakalaka
    Nov 15 '18 at 22:34


















  • Thank you so much. The answer helps me!

    – Boomshakalaka
    Nov 13 '18 at 17:28











  • You know, I'd assumed the macros were in Worksheet modules which are Private so this way wouldn't work - but OP recorded the macros which automatically puts them in normal modules... I should read the questions more thoroughly.

    – Darren Bartrup-Cook
    Nov 13 '18 at 17:29











  • Hi@GTPV, I am a little confused about Sheet1.macroNameNotUnique What should be the input for "macroNameNotUnique"?

    – Boomshakalaka
    Nov 13 '18 at 19:26











  • @Boomshakalaka glad I could help. If your macros require no input then there should be no input when you call the macros. If some of your macros do not have a unique name then you first need to specify the name of the module where the macro is located. For instance: "module1.macroNameNotUnique". Finally, if your macro requires an input then you just add it after. For example: "uniqueMacroName input1, input2, inputN"

    – GTPV
    Nov 14 '18 at 14:33











  • @GTPV Thanks for the reply

    – Boomshakalaka
    Nov 15 '18 at 22:34

















Thank you so much. The answer helps me!

– Boomshakalaka
Nov 13 '18 at 17:28





Thank you so much. The answer helps me!

– Boomshakalaka
Nov 13 '18 at 17:28













You know, I'd assumed the macros were in Worksheet modules which are Private so this way wouldn't work - but OP recorded the macros which automatically puts them in normal modules... I should read the questions more thoroughly.

– Darren Bartrup-Cook
Nov 13 '18 at 17:29





You know, I'd assumed the macros were in Worksheet modules which are Private so this way wouldn't work - but OP recorded the macros which automatically puts them in normal modules... I should read the questions more thoroughly.

– Darren Bartrup-Cook
Nov 13 '18 at 17:29













Hi@GTPV, I am a little confused about Sheet1.macroNameNotUnique What should be the input for "macroNameNotUnique"?

– Boomshakalaka
Nov 13 '18 at 19:26





Hi@GTPV, I am a little confused about Sheet1.macroNameNotUnique What should be the input for "macroNameNotUnique"?

– Boomshakalaka
Nov 13 '18 at 19:26













@Boomshakalaka glad I could help. If your macros require no input then there should be no input when you call the macros. If some of your macros do not have a unique name then you first need to specify the name of the module where the macro is located. For instance: "module1.macroNameNotUnique". Finally, if your macro requires an input then you just add it after. For example: "uniqueMacroName input1, input2, inputN"

– GTPV
Nov 14 '18 at 14:33





@Boomshakalaka glad I could help. If your macros require no input then there should be no input when you call the macros. If some of your macros do not have a unique name then you first need to specify the name of the module where the macro is located. For instance: "module1.macroNameNotUnique". Finally, if your macro requires an input then you just add it after. For example: "uniqueMacroName input1, input2, inputN"

– GTPV
Nov 14 '18 at 14:33













@GTPV Thanks for the reply

– Boomshakalaka
Nov 15 '18 at 22:34






@GTPV Thanks for the reply

– Boomshakalaka
Nov 15 '18 at 22:34


















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283956%2fhow-to-create-a-macro-and-run-multiple-macros-consequentially%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

What does pagestruct do in Eviews?

Dutch intervention in Lombok and Karangasem

Channel Islands