How to read the current grouping of a pivotfield in a pivottable

M

minimaster

I would like to read/save with VBA the current grouping of a
pivotfield (a date either grouped by month, quarter or year) so I can
restore it later via VBA.

Anyone an idea how I can read the current grouping of pivot field?

This is a code example how the grouping can be doen with VBA. But how
can I read the group status???
' Group Date by Month, Quarter, Year
pt.PivotFields("DetailDate").LabelRange.Group Start:=True, _
End:=True, periods:= _
Array(False, False, False, False, True, True, True)
 
P

Patrick Molloy

you can loop through each item in the fields collection and get the
orientation, eg Page, Row,Column ot Data
 
M

minimaster

That is absolutely correct. But I found no way to read the current
grouping. Can you give me hint how I can read for example the grouping
of a particular rowfield?
 
P

Patrick Molloy

explain what you mean by grouping? do you mean the order that the fields
appear?
 
M

minimaster

No,
I posted in the first posting some code that shows how you can group
data in a pivot table. Most commonly this is used to group data that
is date based data by months, by quarters or by years. This means you
have a pivot field as a row field or as a column field and instead of
letting it show up with all the individual dates you let it group for
instance by quarters. Manually you do that be rightclicking the
pivotfield label and then select "Group and Show Detail" ->
"Group...".
Understood? I want to read with VBA the current grouping settings. And
I can't find a straight fwd way to do it.
 
P

Patrick Molloy

sorry - i missed your response. I need to do some research unless you get
an answer elsewhere
 
M

minimaster

My research did not yield any solution yet, coming to the conclusion
that I have to develop a skunk work solution to detect, read and save
the current grouping settings for a specific pivot field item.

But still looking for ideas if anyone has one.
 

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