Calculation Property

Microsoft Excel Visual Basic

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.

ShowCalculation 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 = xlCalculationManual
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