PivotCell オブジェクト (Excel)

ピボットテーブル レポート内のセルを表します。

注釈

Range コレクションの PivotCell プロパティを使用して、PivotCell オブジェクトを取得します。

PivotCell オブジェクトが返されたら、ColumnItems または RowItems プロパティを使用して、選択した数値を表す列または行軸の項目に対応する PivotItems コレクションを決定できます。

PivotCell オブジェクトが返された後、PivotCellType プロパティを使用して、特定の範囲のセルの種類を決定できます。

次の使用例は、ピボットテーブルのセル 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 PivotCell at A5 is a data item." 
 Else 
 MsgBox "The PivotCell 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

次の使用例は、セル B5 のデータ アイテムが含まれる列フィールドを調べます。 次に、その列フィールドのタイトルが "在庫" に一致するかどうかを調べて、通知します。 この例では、作業中のワークシートにピボットテーブルが存在し、ワークシートの列 B にピボットテーブルの列フィールドが含まれていることを前提としています。

Sub CheckColumnItems() 
 
 ' Determine if there is a match between the item and column field. 
 If Application.Range("B5").PivotCell.ColumnItems.Item(1) = "Inventory" Then 
 MsgBox "Item in B5 is a member of the 'Inventory' column field." 
 Else 
 MsgBox "Item in B5 is not a member of the 'Inventory' column field." 
 End If 
 
End Sub

メソッド

プロパティ

関連項目

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。