+ Reply to Thread
Results 1 to 5 of 5

Excel Not Finishing Calculation Before Moving to Next Line of Code

Hybrid View

  1. #1
    Registered User
    Join Date
    11-12-2013
    Location
    Stockton, Alabama
    MS-Off Ver
    2007 & 2003
    Posts
    4

    Excel Not Finishing Calculation Before Moving to Next Line of Code

    Hello everyone,

    I have a very odd problem. I have found a few instances where other people had this problem, but I have yet to find a solution.

    I have a macro-enabled workbook that performs several time consuming tasks, and it takes a fair amount of computing time (about 10 minutes, start to finish). Near the end of the macro, it opens several Excel files, all of which are linked to the file with the macro, and performs a "save as" function to save them as CSV files or tab delimited, depending on the end purpose for the file. I noticed the "saved as" files did not appear to have the correct data. So, I began to investigate and realized it was opening and saving the files before the calculations in the original worksheet were complete.

    If I manually "step into" the macro and run it line by line, it works beautifully. However, if I just let it go, it will "outrun" itself by moving to the next line of code before the calculations from the previous step are complete. I am stumped. I have tried:

    1. Wait commands
    2. Do events Loops
    3. CalculateFull
    4. Manual and Automatic Calculations
    5. Calculate the workbook
    6. Calculate each sheet individually
    7. I am sure more that I cannot remember.

    Any ideas how to make the macro wait until the calculations are 100% complete before proceeding?

  2. #2
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,887

    Re: Excel Not Finishing Calculation Before Moving to Next Line of Code

    http://stackoverflow.com/questions/1...e-has-finished
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  3. #3
    Registered User
    Join Date
    11-12-2013
    Location
    Stockton, Alabama
    MS-Off Ver
    2007 & 2003
    Posts
    4

    Re: Excel Not Finishing Calculation Before Moving to Next Line of Code

    Jacc,

    Thank you for the information. Unfortunately, that did not work. The only thing I can think of, is Excel completes one set of calculations, which triggers another set, and another set, and so on. Maybe it is catching those split seconds calculations are not running between iterations?

  4. #4
    Registered User
    Join Date
    12-07-2012
    Location
    montreal, canada
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Excel Not Finishing Calculation Before Moving to Next Line of Code

    DBCox, I am having the same issue with one of my macros.
    Did you find something?

  5. #5
    Registered User
    Join Date
    11-20-2005
    Posts
    33

    Re: Excel Not Finishing Calculation Before Moving to Next Line of Code

    I am so sorry it took me this long to reply. The email notification got buried in my inbox.

    Someone suggested I try:
    Application.CalculateUntilAsyncQueriesDone

    It worked! Apparently, the external data was not completely updated before calculations began. This code prevents that.

    Hope it helps!

+ 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. chart generation for many data sets, setting ranges, need help finishing code
    By ESCOengineer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-29-2013, 09:15 AM
  2. [SOLVED] SQL Code does not fit in one line in Excel VBA, automatically moves down one line
    By trizzo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-11-2013, 10:56 AM
  3. [SOLVED] Moving Contents of Line to End of Previous Line in Word 2010 doc
    By staggers47 in forum Word Formatting & General
    Replies: 4
    Last Post: 12-15-2012, 09:17 AM
  4. [SOLVED] Excel Find Starting and finishing Time
    By Iceman1988 in forum Excel General
    Replies: 8
    Last Post: 07-16-2012, 10:23 AM
  5. Macro - Moving to the next line and repeating code (Loop)
    By joe3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2012, 10:02 AM

Tags for this Thread

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