Question : Change pivot table page fields in Excel 2007 with VBA

I am creating VBA code to modify the page filter (report filter) in a large number of Excel 2007 pivot tables.  I used the macro recorder to create the code.  The code changes all pivot tables so that they refer to the same Division.  Regions associated with the Division are then show in the pivot tables.  The pivot tables are spaced so that there is there is room for them to show all the Regions in the largest Division.  

The problem I am running into is that the macro recorder adds a line of code that clears the page filter before it sets the page filter to the new Division.  This causes the pivot tables to overlap.  I do not have this problem when I change the page filter manually.  My question is can I safely remove the line of code the clears the filter value, and just use the line of code that sets the page filter to a new value?  I have seen sample code that suggests this will work, but I need to confirm that this will not cause any undesirable side effects.
Code Snippet:
1:
2:
3:
Sheets("TablesPage_1").Select
    ActiveSheet.PivotTables("PT_BSC1_1").PivotFields("Division").ClearAllFilters
    ActiveSheet.PivotTables("PT_BSC1_1").PivotFields("Division").CurrentPage = "Central"

Answer : Change pivot table page fields in Excel 2007 with VBA

Yes,

Changing the CurrentPage of the PivotField that is your Page field will do the same thing as the manual selection without any undesirable effects.  No need for the .ClearAllFilters line the recorder put in.

WC
Random Solutions  
 
programming4us programming4us