Hiding Pivot Table Items- VBA -An Excel Bug?
Posted by Andrew on May 04, 2001 4:25 AM
When I use a button to call the routine it breaks because it cannot find the items in the pivot table. However when I step through the code it works fine. Can anybody help?
---------------------------------
Sub ConfigueDates2()
Dim DateValueRemove As String
Dim EndWeek As String
Dim EndLastWeek As String
EndWeek = Range("EndWeek")
EndLastWeek = Range("EndLastWeek")
Sheets("Sheet2").Select
With ActiveSheet.PivotTables("PivotTable3").PivotFields("Date")
For x = 1 To .PivotItems.Count
DateValueRemove = .PivotItems(x).Name
If DateValueRemove = EndWeek Then GoTo NextDate
If DateValueRemove = EndLastWeek Then GoTo NextDate
.PivotItems.Item(DateValueRemove).Visible = False
NextDate:
Next
End With
End Sub