ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trouble setting visible property for PivotItems (https://www.excelbanter.com/excel-programming/355840-trouble-setting-visible-property-pivotitems.html)

ridawg

Trouble setting visible property for PivotItems
 
Hey,

I'm trying to set the visibility of the PIvotItems in a for a particular
PivotField. I keep getting the following error:
"Run Time Error: 1004. Unable to set the visible property of the PivotItem
class."

Here's my code (just the loop I'm having trouble with):
'Select only the current week to display
PF.AutoSort xlManual, "Week Ending"
For Each PI In PF.PivotItems
If PI.Name <= DateAdd("ww", -1, Date) Then
PI.Visible = False
End If
Next PI
'End Select only the current week to display

Basically, I have pivot table with data for each week of the current year
and my goal is to display the most recent week which in this case would be
the current date minus 1 week.

Any help would be greatly appreciated!

--
-ridawg


All times are GMT +1. The time now is 12:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com