I need to select 2 items (months that are chosen by a user) in a pivot table. I can either put the Months as PageItems (Select Multiple) or FieldItems, either way I will get the results I need (when selected manually).
When choosing one item, no problem.
I use the code Sheets("Sheet1").Range("A3") = Sheets("Sheet2").Range("B4")
Where Sheet1!A3 is the PageItem for month
But to select 2 items is killing me.
If I put months as PageItems then I can't just use a simple replace I showed above. I somehow need to tell the pivot table to uncheck whatever is checked and then check
(make true) what the user has selected. When I tried to record a macro to
do this it listed every item in thePageField and set them to false and then set the selections to true. The problem with this is that I dont know what all the PageItems will be. I do know that the selections will be in the data.
So if I put Months in PageField I need one stmt to set "all" to false. Something like this:
PivotTables("PivotTable59").PivotFields("Month").PivotItems("(All)") = False
PivotTables("PivotTable59").PivotFields("Month").PivotItems("2/1/2010") = True
PivotTables("PivotTable59").PivotFields("Month").PivotItems("3/1/2010") = True
If I put Months as Field Items then I can use the direct replace shown above . . .
but instead of replacing the current item with the new item it just adds the date to what is already selected. If 2 were selected it will show 3 etc. so I still need to set all items to false and then set the items selected to True.
Thanks
When choosing one item, no problem.
I use the code Sheets("Sheet1").Range("A3") = Sheets("Sheet2").Range("B4")
Where Sheet1!A3 is the PageItem for month
But to select 2 items is killing me.
If I put months as PageItems then I can't just use a simple replace I showed above. I somehow need to tell the pivot table to uncheck whatever is checked and then check
(make true) what the user has selected. When I tried to record a macro to
do this it listed every item in thePageField and set them to false and then set the selections to true. The problem with this is that I dont know what all the PageItems will be. I do know that the selections will be in the data.
So if I put Months in PageField I need one stmt to set "all" to false. Something like this:
PivotTables("PivotTable59").PivotFields("Month").PivotItems("(All)") = False
PivotTables("PivotTable59").PivotFields("Month").PivotItems("2/1/2010") = True
PivotTables("PivotTable59").PivotFields("Month").PivotItems("3/1/2010") = True
If I put Months as Field Items then I can use the direct replace shown above . . .
but instead of replacing the current item with the new item it just adds the date to what is already selected. If 2 were selected it will show 3 etc. so I still need to set all items to false and then set the items selected to True.
Thanks