(Excel) 的 PivotCell.PivotCellType 屬性

傳回其中一個 XlPivotCellType 常數,識別儲存格對應的樞紐分析表實體。 唯讀。

語法

運算式PivotCellType

表達 代表 PivotCell 物件的變數。

範例

本範例將判斷樞紐分析表中的 A5 儲存格是否為資料項目,並通知使用者。 此範例假設活動工作表上有一個樞紐分析表,而儲存格 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

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應