vba pivot table group test

cdjones

New Member
Joined
Sep 30, 2009
Messages
8
If I ungroup a grouped field then VBA throws an error so I need a way to test if a field in a pivot table is grouped.

ie:

if pf is grouped then
pf.ungroup
endif

anyone ?
Thankd
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I'm not sure if there's an easy answer here... the likes of TotalLevels will help to some extent but not where this is only 1 level of Grouping (ie Dates by Month) given an ungrouped field would also return 1.

Hopefully this bump will trigger others who may be aware of a solution.
 
Upvote 0
It's easier just to handle (or ignore) the error.
 
Upvote 0
Rory, I remain curious though as to whether or not there exists a fool proof way of establishing the Grouped status of any given field ?
 
Upvote 0
Not that I am aware of, no. (As it happens this came up fairly recently in a certain newsgroup full of heavy hitters, and no-one there knew of a good method).
 
Upvote 0
Re: vba pivot table group test [SOLVED]

all, thanks

on error resume next
pf.ungroup
on error goto 0

?
 
Upvote 0

Forum statistics

Threads
1,214,525
Messages
6,120,051
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top