Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a workbook that has a bunch of pivottables that are based on an
Analysis Services cube. Each of the pivottables has a filter on it that limits the row data to one customer account. Once a week I go in an manually change the filter for the "Account ID" field so that the pivottables show the data in the pivots for a different account. All works great, except it is manual so I took some time and tried to write some VB code to automate the update for all pivots. To get started a recorded a macro. The macro has the following code: ActiveSheet.PivotTables("PivotTable1").PivotFields ( _ "[Account].[Account ID].[Account ID]").ClearAllFilters ActiveSheet.PivotTables("PivotTable1").PivotFields ( _ "[Account].[Account ID].[Account ID]").PivotFilters.Add Type:=xlCaptionEquals _ , Value1:="194108" Here's what I don't understand, when I run the macro, I get an "Out of Memory" error when it attempts to "ClearAllFields". So I removed that line of code and I am just running the second line... ActiveSheet.PivotTables("PivotTable1").PivotFields ( _ "[Account].[Account ID].[Account ID]").PivotFilters.Add Type:=xlCaptionEquals _ , Value1:="194108" The thing is, when I run this line by itself, I get an error: "Run-time error '1004': Application-defined or object-defined error" Why am I able to do this manually, when I recorded the macro, but not when run it through code? My guess is that it doesn't let me "add" a filter to something that already has the filter (hence the "ClearAllFilters" that the recorded macro had). Is there a workaround where I could just change the filter value? I tried just setting the value1 parameter (which says is read/write) with the following: Worksheets("Major App Usage over 30 days").PivotTables("Pivottable1").RowFields(1).Piv otFilters(1).Value1 = "132238" But that didn't work because I got a "Wrong number of arguments or invalid property assignment". Any ideas for a workaround? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
use function to change a string to function's parameter | Excel Worksheet Functions | |||
Excel NPV initial cost in value1 and first year return in value2? | Excel Worksheet Functions | |||
EXCEL: VBE code for a push-down stack (Date,Value1,.....) | Excel Programming | |||
scatter plots and "label" as ("X" value1, value2) | Charts and Charting in Excel | |||
How to dinamic cell that searches for "value1 & value2" in table. | Excel Discussion (Misc queries) |