Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub HideItems()
Dim pi As PivotItem Dim pf As PivotField Dim s As String, dt As Date With ActiveSheet.PivotTables("PivotTable2") .ManualUpdate = True Set pf = .PivotFields("Month") pf.AutoSort xlManual, pf.SourceName For Each pi In pf.PivotItems s = pi.Name dt = CDate(s) If Year(dt) < Year(Date) Then pi.Visible = False End If Next pf.AutoSort xlAscending, pf.SourceName .ManualUpdate = False End With End Sub -- Regards, Tom Ogilvy "Aaron" wrote: My button has this code now to control the Page feild of the PT: With ActiveSheet.PivotTables("PivotTable2").PivotFields ("Month") .PivotItems("9/30/2006").Visible = False .PivotItems("10/31/2006").Visible = False .PivotItems("11/30/2006").Visible = False .PivotItems("12/31/2006").Visible = False End With Thus leaving only the 2007 months visable, thus creating a YTD view. But when the year flips to 2008 I want the code to automatically Hide all 12 months in 2007 as well. I was thinking maybe I could set all pivotitems in pivotfeild Month to false if < cell A1 which I could set a formula in. What would this code look like, or is there a better way? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pivot Table Reports Year to date Values | Excel Discussion (Misc queries) | |||
Create refresh button in worksheet to refresh Pivot Table Data | Excel Worksheet Functions | |||
Pivot Table Year to Date | Excel Programming | |||
Setting up "Year to Date" Calculations in a Pivot Table | Excel Worksheet Functions | |||
create a date from year, day and month | Excel Worksheet Functions |