Calculation Property

Microsoft Excel Visual Basic

Show All

Calculation Property

       

Calculation property as it applies to the Application object.

Returns or sets the calculation mode. Read/write XlCalculation.

XlCalculation can be one of these XlCalculation constants.
xlCalculationAutomatic
xlCalculationManual
xlCalculationSemiautomatic

expression.Calculation

expression   Required. An expression that returns one of the above objects.

 

Calculation property as it applies to the PivotField object.

Returns or sets the type of calculation performed by the specified field. This property is valid only for data fields. Read/write XlPivotFieldCalculation.

XlPivotFieldCalculation can be one of these XlPivotFieldCalculation constants.
xlDifferenceFrom
xlIndex
xlNoAdditionalCalculation
xlPercentDifferenceFrom
xlPercentOf
xlPercentOfColumn
xlPercentOfRow
xlPercentOfTotal
xlRunningTotal

expression.Calculation

expression   Required. An expression that returns one of the above objects.

 

Remarks

For OLAP data sources, this property can only return or be set to xlNormal.

Example

This example causes Microsoft Excel to calculate workbooks before they are saved to disk.

Application.Calculation = xlCalculateManual
Application.CalculateBeforeSave = True

This example sets the data field in the PivotTable report on Sheet1 to calculate the difference from the base field, sets the base field to the field named "ORDER_DATE," and then sets the base item to the item named "5/16/89."

With Worksheets("Sheet1").Range("A3").PivotField
    .Calculation = xlDifferenceFrom
    .BaseField = "ORDER_DATE"
    .BaseItem = "5/16/89"
End With