April 2006
Beginner
1114 pages
98h 16m
English
Use the PivotItemList collection to find the row and column of a PivotCell. Use the PivotCell object’s RowItems and ColumnItems properties to get a reference to this collection. The PivotItemList collection has the following members:
Application Count Creator Item Parent
The following code displays the row and column of a selected cell in a pivot table’s data area:
Sub GetRowAndColumn( )
Dim pc As PivotCell, pi As PivotItem
On Error Resume Next
' Get the pivot cell
Set pc = Selection.PivotCell
' Show the row this item belongs to.
For Each pi In pc.RowItems
Debug.Print "Row: " & pi.Value
Next
' Show the column this item belongs to.
For Each pi In pc.ColumnItems
Debug.Print "Column: " & pi.Value
Next
If Err Then Debug.Print "Selection is not in the data area."
On Error GoTo 0
End SubRead now
Unlock full access