+ Reply to Thread
Results 1 to 8 of 8

how to keep macros from running at the same time?

  1. #1
    Registered User
    Join Date
    01-22-2014
    Location
    Potosi, MO
    MS-Off Ver
    Excel 2013
    Posts
    64

    how to keep macros from running at the same time?

    I posted this question yesterday, but didn't word it very well, so I closed that thread and thought Id see if anyone can give me insight with the question worded like this... With the code below, what can I add to make sure that the macro that runs every 5 minutes, does not fall at the exact same time as my other macros? It must have happened the other day, because it took formatting from one of my workbooks, and applied it to another workbook. Each of those workbooks get opened from a macro and things done, so for it to have happened, it had to have been trying to run both macros at the same time, and did the formatting to the wrong workbook. Any Help?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: how to keep macros from running at the same time?

    Hi - I do not believe it is possible to run two excel macros at the same time. VBA is a single-threaded language so it cannot run two pieces of code simultaneously. This assumes that all the macros are being run from the same application instance.

    I'd therefore suggest you need to post more information about the project, for example, the other macros involved and some of the workbooks in order to arrive at a solution.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,196

    Re: how to keep macros from running at the same time?

    Rather than worry about whether or not they run at the same time, you would probably do better to ensure that the code only operates on the workbook it is intended to. So you need to fully qualify all sheet references and ranges and refer to ThisWorkbook.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    01-22-2014
    Location
    Potosi, MO
    MS-Off Ver
    Excel 2013
    Posts
    64

    Re: how to keep macros from running at the same time?

    Could you give me an example of how to do this? Below is the code from one of the macros, just clearing some cells. What can I add to it, to make sure that it only does it to this ThisWorkBook? Thanks

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: how to keep macros from running at the same time?

    Instead of:
    Please Login or Register  to view this content.
    Try:
    Please Login or Register  to view this content.
    or to stop needing to right it out each time:
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    That said, you can probably amalgamate all those ranges, i.e.
    Please Login or Register  to view this content.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,196

    Re: how to keep macros from running at the same time?

    Untested:

    Please Login or Register  to view this content.

    Regards, TMS

  7. #7
    Registered User
    Join Date
    01-22-2014
    Location
    Potosi, MO
    MS-Off Ver
    Excel 2013
    Posts
    64

    Re: how to keep macros from running at the same time?

    Thanks, seemed to have worked great!

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,196

    Re: how to keep macros from running at the same time?

    You're welcome. Thanks for the rep.

+ 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. Running two macros as one
    By Seraph84 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-11-2011, 01:48 AM
  2. Prevent two macros from running at the same time
    By Kreef in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-31-2011, 10:36 PM
  3. Running Macros
    By in forum Excel General
    Replies: 0
    Last Post: 07-06-2006, 10:45 AM
  4. running macros from IF
    By CJ in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-30-2006, 12:10 PM
  5. HELP - Running Macros in VBA
    By Louise in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 04-06-2005, 12:06 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