Microsoft Office Tutorials and References
In Depth Information
20.5.5 Additional Members of the PivotTable Object
The following code selects cell E12 of the pivot table in Figure 20-10 :
ActiveSheet.PivotTables("Sales&Trans").PivotSelect _
"'LOS ANGELES' Franchise 'Sale' '2'", xlDataOnly
The following code selects the labels and data for Boston and New York:
ActiveSheet.PivotTables("Sales&Trans"). _
PivotSelect "'Store City'[BOSTON,'NEW YORK']", xlDataAndLabel
If we replace the comma with a colon:
ActiveSheet.PivotTables("Sales&Trans"). _
PivotSelect "'Store City'[BOSTON:'NEW YORK']", xlDataAndLabel
then all items from Boston to New York (that is, all items) are selected.
The PivotSelection property returns or sets the PivotTable selection, again in standard PivotTable
selection format. Setting this property is equivalent to calling the PivotSelect method with th e
Mode argument set to xlDataAndLabel .
20.5.5 Additional Members of the PivotTable Object
Let us take a look at some additional members of the PivotTable object.
20.5.5.1 AddFields method
We have seen this method in action earlier in this chapter.
20.5.5.2 CalculatedFields method
It is possible to add calculated fields to a pivot table. These are fields that are not part of the
original source data, but instead are calculated from source fields using a formula.
The CalculatedFields method returns the CalculatedFields collection of all calculated fields. To
add a new calculated field, we use the Add method of the CalculatedFields collection. The syntax
is:
CalculatedFieldsObject .Add( Name , Formula )
 
Search JabSto ::




Custom Search