Calculation


Calculation Engine

Excel has a very complicated algorithm for choosing which cells to calculate in order to return the correct value from a formula.
The calculation algorithm was changed in Excel 2000 and again in Excel 2002.
Excel will always try and calculate the minimum number of cells possible and will only recalculate cells when:
1) cells, formulas, values or names have changed.
2) cells have been flagged as needing a recalculation.
3) cells dependent on other cells, formulas, names or values that need recalculating.


Calculation Options

For more details on VBA Calculation options, please refer to the Options page ??


Calculating all the open workbooks

Pressing F9 recalculates any cells that have changed in all the open workbooks.
Application.Calculate returns an error if there are no workbooks open.

If Workbooks.Count > 0 Then 
   Application.Calculate
End If


Calculating all the worksheets in a Workbook

There is no quick way to do this so you have to loop through each worksheet in that particular workbook.

For Each WshName in ActiveWorkbook.Worksheets 
'copy from depository and/or put in depository
Next


Calculating all the cells on just a particular worksheet

Pressing (Shift + F9) is the same as pressing F9 except that it only recalculates cells on the active worksheet.

ActiveSheet.Calculate 
Worksheets(1).Calculate


Calculating a particular range on a particular worksheet

Worksheets(1).Range("A1:B10").Calculate 


objRange.Calculate

This will fail if calculation is set to manual and iteration is enabled.

Range("A4:C10").Calculate 



Application.CalculationInterruptKey



Application.Iteration 



Indicates whether Excel calculations are in progress, pending or done

Application.CalculationState = xlCalculationState.xlPending 


Returns the Excel version and calculation engine version used when the file was last saved.

Application.CalculationVersion 


Stops any recalculations in an Excel application

Application.CheckAbort 



Important

If a calculation find more than 65,536 dependencies then a full calculation is perfomed.


© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

Top

PrevNext