Function Property

Microsoft Excel Visual Basic

Show All

Function Property

       

Returns or sets the function used to summarize the PivotTable field (data fields only). Read/write XlConsolidationFunction.

XlConsolidationFunction can be one of these XlConsolidationFunction constants.
xlAverage
xlCountNums
xlMin
xlStDev
xlSum
xlVar
xlCount
xlMax
xlProduct
xlStDevP
xlUnknown
xlVarP

expression.Function

expression   Required. An expression that returns one of the objects in the Applies To list.

Remarks

For OLAP data sources, this property is read-only and always returns xlUnknown. For other data sources, this property cannot be set to xlUnknown.

Example

This example sets the Sum of 1994 field in the first PivotTable report on the active sheet to use the SUM function.

ActiveSheet.PivotTables("PivotTable1") _
    .PivotFields("Sum of 1994").Function = xlSum