+ Reply to Thread
Results 1 to 6 of 6

Can a macro run in the background?

  1. #1
    Registered User
    Join Date
    04-19-2012
    Location
    U.S.
    MS-Off Ver
    Excel 2003
    Posts
    6

    Can a macro run in the background?

    I have absolutely no programming experience, and would like some help! I made a macro and the macro itself works great, but I have two questions:

    1.) The macro takes a while to run, during that time my computer seems to not let me use other programs (I can but the program constantly "deselects" itself so it is difficult) Is there any way to prevent the macros from doing this, so that I can do other things while the macro is running?

    2.) I have the macro set to change cell A4 to a particular value, then right after that to change cell B4 to equal A4+1. However, every other time that it changes A4, the value of B4 changes to a decimal (ex. 1.5, 2.5, 3.5, etc). A4 is always an integer, so B4 should always be an integer also. I think that this may be because it changes B4 while A4 is still changing so it takes the midpoint of the two A4 values, but I am not sure. Any ideas?

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,715

    re: Can a macro run in the background?

    Hi

    You will not be able to run other excel macros or work on other excel sheets when an excel macro is running, but you ought to be able to run other programs.

    Macros perform their instructions in the order you write them, so if you codes sets A4 to “5” and then B4 to “=A4 + 1” it should always return 6. I guess there is something else in the macro producing your unexpected result. Perhaps you could post your code and we’ll take a look?

  3. #3
    Registered User
    Join Date
    04-19-2012
    Location
    U.S.
    MS-Off Ver
    Excel 2003
    Posts
    6

    re: Can a macro run in the background?

    Thanks for the fast reply! I actually figured out what it was in the code that was returning the decimals, so that is fixed. But as for other programs, I can run them, but my computer constantly "de-selects" them and reselects Excel. In other words, if I was running the macro while I was typing in this box, my internet explorer would constantly unselect and I would have to keep clicking in this box continuously to be able to keep typing. Hope that makes sense!

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    re: Can a macro run in the background?

    1.) You're macro could probably be made to run in under a second. Post your macro code. Or better yet, your workbook.
    2.) Excel doesn't work like that.

  5. #5
    Registered User
    Join Date
    04-19-2012
    Location
    U.S.
    MS-Off Ver
    Excel 2003
    Posts
    6

    re: Can a macro run in the background?

    Quote Originally Posted by AlphaFrog View Post
    1.) You're macro could probably be made to run in under a second. Post your macro code. Or better yet, your workbook.
    2.) Excel doesn't work like that.
    It runs about 40 simulations from an add-in program and those take a really long time.

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    re: Can a macro run in the background?

    Within your macro code, eliminate any commands with .Select or .Activate as those take up a lot of resources and are generally not needed. Also, try to incorporate the DoEvents function to surrender execution of the macro during loops.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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