J
jackie
Hi,
I have 4 filters on 3 pivot tables, A, F, N. M. I need a button that when
selected will automatically select one of the filters.
I tried to do it by setting the autofilters on the three charts to Show All.
I then recorded a macro for A, for example by select A from each pivot table.
I did this for all four filters. and added the macros to buttons. The first
one works, but when you hit any of the subsequent buttons, you get an error.
In the data below, the last line for N in Chart 38 is in yellow when
debugged.
ActiveWindow.Visible = False
Windows("Force Protection - Corporate.xls").Activate
ActiveSheet.ChartObjects("Chart 38").Activate
With ActiveChart.PivotLayout.PivotTable.PivotFields("Service")
.PivotItems("A").Visible = False
.PivotItems("M").Visible = False
.PivotItems("N").Visible = False
End With
ActiveWindow.Visible = False
Windows("Force Protection - Corporate.xls").Activate
ActiveSheet.ChartObjects("Chart 40").Activate
With ActiveChart.PivotLayout.PivotTable.PivotFields("Service")
.PivotItems("A").Visible = False
.PivotItems("M").Visible = False
.PivotItems("N").Visible = False
End With
ActiveWindow.Visible = False
Windows("Force Protection - Corporate.xls").Activate
ActiveSheet.ChartObjects("Chart 48").Activate
With ActiveChart.PivotLayout.PivotTable.PivotFields("Service")
.PivotItems("A").Visible = False
.PivotItems("M").Visible = False
.PivotItems("N").Visible = False
End With
End Sub
Can someone tell me what is wrong and how I can fix it. Thanks.
I have 4 filters on 3 pivot tables, A, F, N. M. I need a button that when
selected will automatically select one of the filters.
I tried to do it by setting the autofilters on the three charts to Show All.
I then recorded a macro for A, for example by select A from each pivot table.
I did this for all four filters. and added the macros to buttons. The first
one works, but when you hit any of the subsequent buttons, you get an error.
In the data below, the last line for N in Chart 38 is in yellow when
debugged.
ActiveWindow.Visible = False
Windows("Force Protection - Corporate.xls").Activate
ActiveSheet.ChartObjects("Chart 38").Activate
With ActiveChart.PivotLayout.PivotTable.PivotFields("Service")
.PivotItems("A").Visible = False
.PivotItems("M").Visible = False
.PivotItems("N").Visible = False
End With
ActiveWindow.Visible = False
Windows("Force Protection - Corporate.xls").Activate
ActiveSheet.ChartObjects("Chart 40").Activate
With ActiveChart.PivotLayout.PivotTable.PivotFields("Service")
.PivotItems("A").Visible = False
.PivotItems("M").Visible = False
.PivotItems("N").Visible = False
End With
ActiveWindow.Visible = False
Windows("Force Protection - Corporate.xls").Activate
ActiveSheet.ChartObjects("Chart 48").Activate
With ActiveChart.PivotLayout.PivotTable.PivotFields("Service")
.PivotItems("A").Visible = False
.PivotItems("M").Visible = False
.PivotItems("N").Visible = False
End With
End Sub
Can someone tell me what is wrong and how I can fix it. Thanks.