04 CalcAll - AndrewMB2/Logic-Architect-for-Excel-VBA GitHub Wiki

CalcAll method

Calculates by rows using previously saved formulae. Returns True if successful, otherwise False.

Applies to

TableData ArrData RsetData Xdata XShared

Parameters

Name Type Description
Scratch Range (optional) Scratch area to be used for calculation.

Sometimes there is a requirement to create cumulative calculations across fields as well as records. For this, there is a Formula method where it is possible to supply the formula for subsequent calculation. Then the CalcAll method carries out the calculations and clears the formulae set by the Formula method. The calculation is carried out across fields in the order in which they were defined and then down records.

There are two methods of calculation:

  • To use Application.Evaluate, omit the Scratch parameter. The formula is evaluated as an array formula if necessary, though the length of the formula (after values have been substituted) cannot exceed 255 characters (an Excel limitation).
  • To use spare space on a worksheet, set the Scratch parameter to the first cell. The column starting with this cell is used (and cleared after use). With this method there is no restriction on the length of the formula, though it is not evaluated as an array formula. This method is normally faster.

Please see the Calc method for full information about calculation.