返回一个 Boolean,该 Boolean 用于指明在当前会话过程中,指定的计算成员是否已经与 OLAP 提供程序一起演示。
expression.IsValid
expression 必需。该表达式返回一个 CalculatedMember 对象。
即使数据透视表未与其数据源相连,本属性也返回 True。在查询 IsValid 属性的值以前,必须保证数据透视表与其数据源相连。
本示例通知用户计算成员是否有效。本示例假定数据透视表位于活动的工作表上。
Sub CheckValidity()
    Dim pvtTable As PivotTable
    Dim pvtCache As PivotCache
    Set pvtTable = ActiveSheet.PivotTables(1)
    Set pvtCache = Application.ActiveWorkbook.PivotCaches.Item(1)
    ' Make connection for PivotTable before testing IsValid property.
    pvtCache.MakeConnection
    ' 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