Try this. Put the months to filter in Variables Value1 & Value2
Sub PivotFilters()
Dim Value1 As String, Value2 As String, PT As PivotTable, PF As PivotField, PI As PivotItem
Set PT = ActiveSheet.PivotTables("test"): Set PF = PT.PivotFields("Months")
PT.ClearAllFilters
Value1 = "Sep-16": Value2 = "Oct-16"
For Each PI In PF.PivotItems
If PI.Name = Value1 Or PI.Name = Value2 Then
PF.PivotItems(PI.Name).Visible = True
Else
PF.PivotItems(PI.Name).Visible = False
End If
Next PI
End Sub
If you want to add another filter, add another variable, say for e.g. Value3 and add it between the FOR Each Loop
If PI.Name = Value1 Or PI.Name = Value2 Or PI.Name = Value3 Then
Bookmarks