+ Reply to Thread
Results 1 to 9 of 9

Run multiple Sub with one click in VBA

  1. #1
    Registered User
    Join Date
    01-16-2019
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    38

    Question Run multiple Sub with one click in VBA

    Hello All,
    I have written different sub (methods) to perform different action on my excel file. So far I been running them manually mean, go to each sub and click run button to run that sub. Now I would like to automate them. Can somebody help me as how do I do that?
    BTW I'm new to the VBA.

    Thank you.

  2. #2
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Run multiple Sub with one click in VBA

    Depending on what these macros do, there can be multiple ways of automating this. One would be to create another macro like to run them all:
    Please Login or Register  to view this content.
    Click the * to say thanks.

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Run multiple Sub with one click in VBA

    Have one master sub that calls each subs that you need to run.

    Ex:
    Please Login or Register  to view this content.
    And associate that to single button.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  4. #4
    Registered User
    Join Date
    01-16-2019
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    38

    Re: Run multiple Sub with one click in VBA

    Thanks for your quick reply. Will these run in the order they are called right? Now let's say one of the macro runs longer time to run or do I need to do anything special in between the macros to make sure the previous one ran successfully?

    Thanks again.

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Run multiple Sub with one click in VBA

    VBA is single threaded. So first routine will have to finish running before second one will execute.

    I.E. everything will run in succession.

    Edit: Only time where you'll need to consider timing/waiting will be when external process is run, and waiting for response from it, or when background query is turned on for connections.
    Last edited by CK76; 01-21-2019 at 11:40 AM.

  6. #6
    Registered User
    Join Date
    01-16-2019
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    38

    Re: Run multiple Sub with one click in VBA

    Thanks for your all help. Now if I can add little more to my original questions.

    I run Crystal report and then export the output the excel. Then open a VB Window and paste all these macros and run the last macro (which will call all other macros). Is there a way to save all these macros in a file (somewhere on network drive) and whenever I run my crystal report and export the output to the excel, once that part is done then these macros will run in newly created excel file, instead of following all those manual steps.
    Any help will be appreciated.

    Thanks..

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,519

    Re: Run multiple Sub with one click in VBA

    Have a read on how to use Personal.xlsb

  8. #8
    Registered User
    Join Date
    01-16-2019
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    38

    Re: Run multiple Sub with one click in VBA

    Hello,
    Thanks for your reply. I found a document on how to setup/use personal.xlsb, and by following it I set it up. I have total of 30 macros, plus one Master macro, which runs all those 30 macros. Now if I them manually then those work fine. But if I set them up in personal.xlsb then some of the macros do not run and do not see any error as well, so any idea as what is not setup or missing here?

    Thanks again.

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,519

    Re: Run multiple Sub with one click in VBA

    Instead of a so called Master Macro, if you call Macro1, it will run all the macros as they are called, one after the other.
    We don't know your macros so we can't see what could possibly be the problem.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. one click import from multiple files
    By Usaid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-26-2013, 05:34 PM
  2. Multiple ScrollColumn (but once per click)
    By thomasp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2013, 05:55 AM
  3. Replies: 0
    Last Post: 03-06-2013, 12:52 PM
  4. Excel 2007 : 1 click highlights multiple cells?
    By cuutter in forum Excel General
    Replies: 5
    Last Post: 03-22-2012, 04:32 PM
  5. Right-Click Menu with multiple textboxes
    By ilovelagar in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-15-2009, 10:03 AM
  6. Multiple Comboboxes one click
    By slim1313 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-30-2009, 01:33 PM
  7. click on one cell and multiple are highlighted
    By frustratedinWA in forum Excel General
    Replies: 5
    Last Post: 12-30-2008, 01:29 PM
  8. Clearing multiple cells in 1 click?
    By Lewis Koh in forum Excel Formulas & Functions
    Replies: 103
    Last Post: 09-06-2005, 07:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1