+ Reply to Thread
Results 1 to 4 of 4

Difference btween Automatic and Manual calculations.

  1. #1
    WannaBeExceller
    Guest

    Difference btween Automatic and Manual calculations.

    I have a macro that is running and it is running slow since it has to wait
    for the spreadsheet to do updates. I switch the calculations and it runs
    faster. I am wondering if there is loss of anything. What is the difference
    between the two and how does that affect calculations. Thanks in advance.

  2. #2
    Jim Thomlinson
    Guest

    RE: Difference btween Automatic and Manual calculations.

    When you make a change to a spreadsheet, Excel automatically determines
    (based on the change that you made) which cells need to be re-calculated and
    marks these cells as dirty. In automatic mode the calculation is done
    immediately and the dirty flags are removed. In Manual mode the flags are
    just saved up until you manually run a calculation. If you are running code
    with calculation turned off and you are grabbing the values of dirty cells,
    then you are grabbing the wrong amounts. You just need to be sure that if
    your code makes a change that dirties a cell that you do not use the value of
    that cell until a re-calc is done.

    One more thing... When you toggle the cacluation setting in code it is a
    good idea to use an error handler to reset the calculation in the event of a
    crash.
    --
    HTH...

    Jim Thomlinson


    "WannaBeExceller" wrote:

    > I have a macro that is running and it is running slow since it has to wait
    > for the spreadsheet to do updates. I switch the calculations and it runs
    > faster. I am wondering if there is loss of anything. What is the difference
    > between the two and how does that affect calculations. Thanks in advance.


  3. #3
    WannaBeExceller
    Guest

    RE: Difference btween Automatic and Manual calculations.

    Thank you Jim for you response. I was just wondering how the error handler
    would be implemented. I am using a line that does the recalc
    "worksheet(1).calculate". Thanks in advance.

    "Jim Thomlinson" wrote:

    > When you make a change to a spreadsheet, Excel automatically determines
    > (based on the change that you made) which cells need to be re-calculated and
    > marks these cells as dirty. In automatic mode the calculation is done
    > immediately and the dirty flags are removed. In Manual mode the flags are
    > just saved up until you manually run a calculation. If you are running code
    > with calculation turned off and you are grabbing the values of dirty cells,
    > then you are grabbing the wrong amounts. You just need to be sure that if
    > your code makes a change that dirties a cell that you do not use the value of
    > that cell until a re-calc is done.
    >
    > One more thing... When you toggle the cacluation setting in code it is a
    > good idea to use an error handler to reset the calculation in the event of a
    > crash.
    > --
    > HTH...
    >
    > Jim Thomlinson
    >
    >
    > "WannaBeExceller" wrote:
    >
    > > I have a macro that is running and it is running slow since it has to wait
    > > for the spreadsheet to do updates. I switch the calculations and it runs
    > > faster. I am wondering if there is loss of anything. What is the difference
    > > between the two and how does that affect calculations. Thanks in advance.


  4. #4
    Jim Thomlinson
    Guest

    RE: Difference btween Automatic and Manual calculations.

    sub Test
    on error goto ErrorHandler
    with application
    .calculation = xlManual
    '.screenupdating = false
    '.displayelerts = false
    end with

    'Your Code here

    'No exit sub so the error handler will procedd into this section even
    without an error
    ErrorHandler:
    with application
    .calculation = xlAutomatic
    '.screenupdating = true
    '.displayelerts = true
    end with
    End Sub

    --
    HTH...

    Jim Thomlinson


    "WannaBeExceller" wrote:

    > Thank you Jim for you response. I was just wondering how the error handler
    > would be implemented. I am using a line that does the recalc
    > "worksheet(1).calculate". Thanks in advance.
    >
    > "Jim Thomlinson" wrote:
    >
    > > When you make a change to a spreadsheet, Excel automatically determines
    > > (based on the change that you made) which cells need to be re-calculated and
    > > marks these cells as dirty. In automatic mode the calculation is done
    > > immediately and the dirty flags are removed. In Manual mode the flags are
    > > just saved up until you manually run a calculation. If you are running code
    > > with calculation turned off and you are grabbing the values of dirty cells,
    > > then you are grabbing the wrong amounts. You just need to be sure that if
    > > your code makes a change that dirties a cell that you do not use the value of
    > > that cell until a re-calc is done.
    > >
    > > One more thing... When you toggle the cacluation setting in code it is a
    > > good idea to use an error handler to reset the calculation in the event of a
    > > crash.
    > > --
    > > HTH...
    > >
    > > Jim Thomlinson
    > >
    > >
    > > "WannaBeExceller" wrote:
    > >
    > > > I have a macro that is running and it is running slow since it has to wait
    > > > for the spreadsheet to do updates. I switch the calculations and it runs
    > > > faster. I am wondering if there is loss of anything. What is the difference
    > > > between the two and how does that affect calculations. Thanks in advance.


+ 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