VBA Pivot: show/hide specific levels

Jonstrup

New Member
Joined
Feb 1, 2016
Messages
14
Hi all

Been searching through high and low but haven't found what I was looking for. Perhaps someone here can help.

Quite often I find my self in need of a macro that can hide/show details to a certain level for my Pivot Table in compact mode. It needs to be robust as it should work in various sheets and PivotTables - so hard coding won't work. And although I have tried I have so far failed at making it myself.

Say I have a pivot table in compact mode that has 7 RowFields - it could be and it could less and the values will also vary.

As RowFields(1) it has "names", RowFields(2) it has "stored items", RowFields(3) it has colour - and so on. For each RowField there are alot of pivotItems.

I would like to push a button and use the application inputbox to specify up to which levels detail should be shown. If I say level 2, then all PivotItems detail from RowFields 1 and 2 should be be shown. Rowfields 3 to 7 should be collapsed.

Instead of the input box it could also work with a fixed macro that shows deatails from 1 to 3. I could then just adjust according to needs.


I think I can make the input box work, but the loop through rowfields and PivotItems I can't seem to figure out.

Can some one help?

Best regards
Kasper
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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