AddTotal method as it applies to the GroupingDefs object.
Creates a new total.
expression.AddTotal(GroupingDefName, GroupingFieldName, PageFieldName, TotalType, Index)
expression An expression that returns a GroupingDefs object.
GroupingDefName Required String. Specifies the GroupingDef object to be used to create the total.
GroupingFieldName Required String. Specifies the grouping field to be used to create the total.
PageFieldName Required String. Specifies the PageField object to be used to create the total.
TotalType Required DscTotalTypeEnum .Specifies the function to be used to create the total.
DscTotalTypeEnum can be one of these DscTotalTypeEnum constants. |
dscAny |
dscAvg |
dscCount |
dscMax |
dscMin |
dscNone |
dscStdev |
dscSum |
Index Optional Variant. Specifies where the new total will be placed in the collection.
AddTotal method as it applies to the PivotView object.
Adds a total to the PivotTable view.
expression.AddTotal(Name, Field, Function)
expression An expression that returns a PivotView object.
Name Required String. Specifies the name of the total.
Field Required PivotField . Specifies the field to be used to create the total.
Function Required PivotTotalFunctionEnum . Specifies the function to be used to create the total.
PivotTotalFunctionEnum can be one of these PivotTotalFunctionEnum constants. |
plFunctionAverage |
plFunctionCount |
plFunctionMax |
plFunctionMin |
plFunctionStdDev |
plFunctionStdDevP |
plFunctionSum |
plFunctionVar |
plFunctionVarP |
Example
As it applies to the PivotView object.
Sub Add_Total()
Dim vwView
Dim ptConstants
Dim totNewTotal
Set vwView = PivotTable1.ActiveView
Set ptConstants = PivotTable1.Constants
' Add a new total named "Total Budget" to the current view.
Set totNewTotal = vwView.AddTotal("Total Budget", vwView.Fieldsets("budget").Fields(0), _
ptConstants.plFunctionSum)
' Insert the newly created total into the detail area of the PivotTable.
vwView.DataAxis.InsertTotal totNewTotal
End Sub