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 
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

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.


Calculating a particular range on a particular worksheet


Performing a FULL Calculation - Excel 2002 & Excel 2003

Pressing (Ctrl + Alt + F9) recalculates all cells in all open workbooks regardless of whether they need to be recalculated.
This was introduced in Excel 2002.


For all open workbooks, forces a full calculation of the data and rebuilds the dependencies.
Dependencies are the formulas that depend on other cells. For example, the formula "=A1" depends on cell A1. The CalculateFullRebuild method is similar to re-entering all formulas.


Performing a FULL Calculation - Excel 97 & Excel 2000

You can also use the EnableCalculation property to calculate all the formulas on a worksheet.
Changing this property from False to True will flag all the formulas as uncalculated so next time the worksheet is calculated a "full" calculation will take place.

Dim objWorksheet As Worksheet 
Application.Calculation = xlConstants.xlManual
objWorksheet = Worksheets(2)
objWorksheet.EnableCalculation = False
objWorksheet.EnableCalculation = True

If you wanted to recalculate all the cells in all the open workbooks then you could do the following for all the worksheets in the workbook.

Dim objWorksheet As Worksheet 
Application.Calculation = xlConstants.xlManual
For Each objWorksheet In Workbooks.Worksheets
   objWorksheet.EnableCalculation = False
   objWorksheet.EnableCalculation = True
Next objWorksheet


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



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.


Stops any recalculations in an Excel application



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