+ Reply to Thread
Results 1 to 4 of 4

Application.Calculation issues

  1. #1
    Forum Contributor
    Join Date
    10-06-2015
    Location
    Leeds, England
    MS-Off Ver
    365 Version 2302 Build 16.0.16130.20942
    Posts
    130

    Application.Calculation issues

    I'm creating a program in excel to predict performance of one of our products depending on the conditions of the product. There are multiple calculations and formulas across multiple sheets to eventually give the results. In VBA traditionally we start the code with :

    "Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual"

    To speed the program up a bit.

    And at the end of the routine we set it back to True and xlCalculationAutomatic respectively. Throughout the routine if it gets to a point that a value needs to be calculated to use elsewhere, we stick in a "Application.Calculate".

    Now, I'm running off my code and it gets to the point where I want to calculate and take a figure from the spreadsheet, but after the "Application.Calculate" it isn't calculating and the code is picking up the old value that is still displayed in the cell.

    I've tried different ways of getting it to calculate:

    "Application.Calculation = xlCalculationAutomatic
    Application.Calculation = xlCalculationManual"

    "If Not Application.CalculationState = xlDone then
    Do Events
    End If"

    "Do Until Application.CalculationState = xlDone
    Do Events
    Loop"

    All of these still didn't let the workbook calculate the values, and the "Do Until" method just got stuck in an infinite loop, the calculationstate was never equal to xldone.

    As soon as I stop the code the values calculate within a second.

    Can anyone help?

    Thanks

  2. #2
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Application.Calculation issues

    Need to see your full code or a sample workbook please then we'll be able to offer some advice
    Please do add reputation where you see fit, it's nice to be nice and we all enjoy a pat on the back

    Please also mark your thread as solved once it has been.

  3. #3
    Forum Contributor
    Join Date
    10-06-2015
    Location
    Leeds, England
    MS-Off Ver
    365 Version 2302 Build 16.0.16130.20942
    Posts
    130

    Re: Application.Calculation issues

    Unfortunately I can't do that as there is a lot of sensitive information within the workbook and the coding can not be disclosed, however I did find a solution. As I had created a custom function within the workbook, I had to include a DoEvents line along with the application.calculate for it to update.

  4. #4
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Application.Calculation issues

    Quote Originally Posted by c.davidson View Post
    Unfortunately I can't do that as there is a lot of sensitive information within the workbook and the coding can not be disclosed, however I did find a solution. As I had created a custom function within the workbook, I had to include a DoEvents line along with the application.calculate for it to update.
    Nice one, glad you got it sorted

+ 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. Application.OnTime Huge Issues
    By sparx in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-10-2016, 05:44 AM
  2. Application.GetSaveAsFilename Issues on MAC
    By jblack6572 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-24-2015, 12:57 PM
  3. Application.Onkey issues
    By skb_yfc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-09-2015, 09:56 PM
  4. Issues with Application.DisplayAlert = False
    By euro_andres in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-25-2012, 05:34 PM
  5. Replies: 0
    Last Post: 07-27-2012, 01:04 PM
  6. Calculation issues
    By mattless1 in forum Excel General
    Replies: 4
    Last Post: 08-08-2009, 04:53 PM
  7. Excel 2003 Application Issues
    By ExcelJamie in forum Excel General
    Replies: 0
    Last Post: 09-07-2006, 12:04 AM

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