+ Reply to Thread
Results 1 to 7 of 7

VBA Macro to change filter on a pivot table

  1. #1
    Registered User
    Join Date
    09-23-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    15

    VBA Macro to change filter on a pivot table

    I want to write a macro that will read cell E4 on sheet 'Overview' and change the pivot table filter on sheet 'operationsnotexectued' to what was selected in sheet 'overview' cell E4
    heres what i've come up with, but i'm hitting a wall


    Dim change_pivot_table
    Sheets("overview").Select
    Range("E4").Select
    change_pivot_table = ActiveCell.Value
    Range("G27").Select
    ActiveCell.Value = change_pivot_table

    Sheets("operationsnotexecuted").Select

    ActiveSheet.PivotTables("PivotTable3").PivotFields("REVISION").ClearAllFilters
    Range("B1").Select
    Application.Goto Reference:="change_pivot_table"

  2. #2
    Registered User
    Join Date
    09-23-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: VBA Macro to change filter on a pivot table

    here is where i'm at so far
    ********************


    Sub change_pivot_table()
    '
    ' change_pivot_table Macro
    '
    End Sub

    ******
    i thought the first part of my code would copy the field E2 and use it to filter the pivot table?
    amy help pls?????!!!!????




    Dim change_pivot_table
    Sheets("overview").Select
    Range("E4").Select
    change_pivot_table = ActiveCell.Value
    ActiveCell.Value = change_pivot_table




    Sheets("operationsnotexecuted").Select

    '

    ActiveSheet.PivotTables("pt3").PivotFields("REVISION").ClearAllFilters
    ActiveSheet.PivotTables("pt3").PivotFields("REVISION"). _
    CurrentPage = change_pivot_table

  3. #3
    Registered User
    Join Date
    09-23-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: VBA Macro to change filter on a pivot table

    Sub change_pivot_table()
    '
    ' change_pivot_table Macro
    '




    Dim change_pivot_table
    Sheets("overview").Select
    Range("E4").Select
    change_pivot_table = ActiveCell.Value
    ActiveCell.Value = change_pivot_table




    Sheets("operationsnotexecuted").Select

    '

    ActiveSheet.PivotTables("pt3").PivotFields("REVISION").ClearAllFilters
    ActiveSheet.PivotTables("pt3").PivotFields("REVISION"). _
    CurrentPage = change_pivot_table

  4. #4
    Registered User
    Join Date
    09-23-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: VBA Macro to change filter on a pivot table

    penny dropped heres the solution for future reference

  5. #5
    Registered User
    Join Date
    09-23-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: VBA Macro to change filter on a pivot table

    this code


    Sub change_pivot_table()
    '
    ' change_pivot_table Macro
    '




    Dim change_pivot_table
    Sheets("overview").Select
    Range("E4").Select
    change_pivot_table = ActiveCell.Value
    ActiveCell.Value = change_pivot_table




    Sheets("operationsnotexecuted").Select

    '

    ActiveSheet.PivotTables("pt3").PivotFields("REVISION").ClearAllFilters
    ActiveSheet.PivotTables("pt3").PivotFields("REVISION") = change_pivot_table
    End Sub

  6. #6
    Registered User
    Join Date
    09-23-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: VBA Macro to change filter on a pivot table

    instead of changing the pivot filter, it changes the name of the pivot table, any help on how i can get it to change the filter instead?
    the code works to clear the filters, just not yet select the specified field in the table

  7. #7
    Registered User
    Join Date
    09-23-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: VBA Macro to change filter on a pivot table

    sorry about the spam
    here's the solution

    Sub change_pivot_table()
    '
    ' change_pivot_table Macro
    '




    Dim change_pivot_table
    Sheets("overview").Select
    Range("E4").Select
    change_pivot_table = ActiveCell.Value
    ActiveCell.Value = change_pivot_table




    Sheets("operationsnotexecuted").Select

    '

    ActiveSheet.PivotTables("pt3").PivotFields("Revision").ClearAllFilters
    ActiveSheet.PivotTables("pt3").PivotFields("REVISION").CurrentPage = change_pivot_table
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1