PDA

View Full Version : Pivot table filtering according to current year



expfresocspy
01-18-2012, 08:14 PM
Hello everyone !

Currently I'm working on pivot tables using excel macro and I really need your help in this .

Basically , I need to filter out the year submitted according to the current year . I did this to filter out my pivot :

=======================================================

For Each PivItem In _
PT.PivotFields("Year Submitted").PivotItems
PivItem.Visible = True
Next PivItem

For Each PivItem In _
PT.PivotFields("Year Submitted").PivotItems
Select Case PivItem.Name
Case "2012"
PivItem.Visible = True
Case Else
PivItem.Visible = False
End Select
Next PivItem

=======================================================

But this can only filter out year 2012 . I need to use this workbook for the next couple of years and I dont want to keep modifying the codes . So please help me with this :/ Thankyou so very much <3