Automate PivotFields PivotItems selection in VBA help pleas

megnin

Active Member
Joined
Feb 27, 2002
Messages
340
I have a macro to create a pivot table with a large number of dates that need to be filtered.

Right now it looks like this (much longer list though):

With ActiveSheet.PivotTables("PivotTable5").PivotFields("Book_Date")
.PivotItems("6/8/2000").Visible = False
.PivotItems("10/20/2000").Visible = False
.PivotItems("1/30/2001").Visible = False
.PivotItems("3/9/2001").Visible = False
.PivotItems("4/8/2001").Visible = False

It halts thought, when the new data does not contain a date in the list. ...It halts a lot.

Can I first make ALL .Visible = False then selectively make the dates in a certain range .Visible = True or the dates up to a specified date .Visible = True?

One range I need is: All dates up to 10 working days from today.

Another is: Yesterday only.

Is this something that can be fairly easily done? Be gentle, I'm a novice :wink:

Thanks to any one with any advice!!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,214,826
Messages
6,121,793
Members
449,048
Latest member
greyangel23

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