CustomSubtotalFunction Property

Microsoft Excel Visual Basic

Show All

CustomSubtotalFunction Property

       

Returns the custom subtotal function field setting of a PivotCell object. Read-only XlConsolidationFunction.

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

expression.CustomSubtotalFunction

expression   Required. An expression that returns a PivotCell object.

Remarks

The CustomSubtotalFunction property will return an error if the PivotCell object type is not a custom subtotal. This property applies only to non-OLAP source data.

Example

This example determines if cell C20 contains a custom subtotal function that uses a consolidation function of count and then it notifies the user.  The example assumes a PivotTable exists on the active worksheet.

Sub UseCustomSubtotalFunction()

    On Error GoTo Not_A_Function

    ' Determine if custom subtotal function is a count function.
    If Application.Range("C20").PivotCell.CustomSubtotalFunction = xlCount Then
        MsgBox "The custom subtotal function is a Count"
    Else
        MsgBox "The custom subtotal function is not a Count"
    End If
    Exit Sub

Not_A_Function:
    MsgBox "The selected cell is not a custom subtotal function."

End Sub