CalculatedMember object (Excel)

Represents the calculated fields, calculated items, and named sets for PivotTables with Online Analytical Processing (OLAP) data sources.

Remarks

Use the Add method or the Item property of the CalculatedMembers collection to return a CalculatedMember object.

With a CalculatedMember object, you can check the validity of a calculated field or item in a PivotTable by using the IsValid property.

Note

The IsValid property returns True if the PivotTable is not currently connected to the data source. Use the MakeConnection method of the PivotCache object before testing the IsValid property.

Example

The following example notifies the user whether the calculated member is valid. This example assumes that a PivotTable exists on the active worksheet that contains either a valid or invalid calculated member.

Sub CheckValidity() 
 
 Dim pvtTable As PivotTable 
 Dim pvtCache As PivotCache 
 
 Set pvtTable = ActiveSheet.PivotTables(1) 
 Set pvtCache = Application.ActiveWorkbook.PivotCaches.Item(1) 
 
 ' Handle run-time error if external source is not an OLEDB data source. 
 On Error GoTo Not_OLEDB 
 
 ' Check connection setting and make connection if necessary. 
 If pvtCache.IsConnected = False Then 
 pvtCache.MakeConnection 
 End If 
 
 ' Check if calculated member is valid. 
 If pvtTable.CalculatedMembers.Item(1).IsValid = True Then 
 MsgBox "The calculated member is valid." 
 Else 
 MsgBox "The calculated member is not valid." 
 End If 
 
End Sub

Methods

Properties

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.