How to read location, content of selected cell in pivot table data area?

G

G Lykos

Greetings! Am fumbling with the pivot table object, trying to work around
some idiosyncrasies. Would appreciate help on two things:

1. How do I read the cell value when a cursor is located in the data area,
and associate it with an item value or otherwise locate it in the data area
with respect to the framing fields/items so I can flag the row as not
..visible?

2. Is there an on-line description somewhere of how the parts of the pivot
table object fit together, and VBA access to them?

To give an idea where I'm at - it seems a little wild to need to read the
cell.pivotcell.parent value of a selected cell to discover the name of the
pivot table that the cell resides in, but maybe I just need to shake up the
hierarchical structure that my mind is struggling to impose on what may be a
different way of viewing things.

Thanks for any ideas!
George
 
B

Bernie Deitrick

Gerorge,


Dim myC As Range
Dim i As Integer
Set myC = Selection
With myC.PivotCell
MsgBox .DataField.Name
For i = 1 To .RowItems.Count
MsgBox .RowItems(i).SourceName
Next i
For i = 1 To .ColumnItems.Count
MsgBox .ColumnItems(i).SourceName
Next i
End With

HTH,
Bernie
MS Excel MVP
 
G

G Lykos

Bernie, have experimented with your code - think I'm starting to understand
a little better. A follow-on question, then, is: How does one read the
data area cells starting off within VBA (i.e. no cell selected)? Are they
in an indexed list hanging off of, for example, PivotTables(1).DataField?
The interest here is to test for a particular value, and if found, to set
the corresponding RowField item invisible to cause the row to not be
displayed.

Thanks again!
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top