全部显示

PivotCellType 属性

       

返回 XlPivotCellType 常量之一,该常量识别单元格所对应的数据透视表实体。只读。

expression.PivotCellType

expression   必需。该表达式返回一个 PivotCell 对象。

示例

本示例确定数据透视表中的单元格 A5 是否是一个数据项,并通知用户。本示例假定数据透视表位于活动工作表上。如果单元格 A5 不在数据透视表中,则本示例处理运行错误。

Sub CheckPivotCellType()

    On Error GoTo Not_In_PivotTable

    ' Determine if cell A5 is a data item in the PivotTable.
    If Application.Range("A5").PivotCell.PivotCellType = xlPivotCellValue Then
        MsgBox "The cell at A5 is a data item."
    Else
        MsgBox "The cell at A5 is not a data item."
    End If
    Exit Sub

Not_In_PivotTable:
    MsgBox "The chosen cell is not in a PivotTable."

End Sub