LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 78
Default change/set pivot table autofilter criteria with macro button

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("Se rvice")
.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("Se rvice")
.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("Se rvice")
.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.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofilter with pivot table Inès Excel Worksheet Functions 0 July 29th 08 05:31 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Change pivot table source data via macro Tim879 Excel Discussion (Misc queries) 2 June 1st 07 01:31 PM
Macro to change a Pivot Table David M Excel Discussion (Misc queries) 0 March 22nd 05 05:27 PM


All times are GMT +1. The time now is 01:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"