CalculatedMembers Collection

Excel Developer Reference

A collection of all the CalculatedMember objects on the specified PivotTable.

Remarks

Each CalculatedMember object represents a calculated member or calculated measure.

Use the CalculatedMembers property of the PivotTable object to return a CalculatedMembers collection.

Example
The following example adds a set to a PivotTable, assuming a PivotTable from the FoodMart SQL database exists on the active worksheet.

Visual Basic for Applications
  Sub UseCalculatedMember()
Dim pvtTable As PivotTable

Set pvtTable = ActiveSheet.PivotTables(1)

pvtTable.<strong>CalculatedMembers</strong>.Add Name:="[Beef]", _
    Formula:="'{[Product].[All Products].Children}'", _
    Type:=xlCalculatedSet

End Sub

Bb210105.vs_note(en-us,office.12).gif  Note
For the Add method in the previous example, the Formula argument must have a valid MDX syntax statement. The Name argument has to be acceptable to the Online Analytical Processing (OLAP) provider and the Type argument has to be defined.

See Also