Sub CompareMonths()
Dim pvt As PivotTable
Dim pvi As PivotItem
Dim sMonth As String
sMonth = "Jan"
Set pvt = ActiveSheet.PivotTables(1)
For Each pvi In pvt.PivotFields("Years").PivotItems
If pvi.Name <> "2006" And pvi.Name <> "2007" Then
pvi.Visible = False
End If
Next pvi
pvt.PivotFields("Date").PivotItems(sMonth).Visible = True
For Each pvi In pvt.PivotFields("Date").PivotItems
If pvi.Name <> sMonth Then pvi.Visible = False
Next pvi
End Sub
|