+ Reply to Thread
Results 1 to 9 of 9

Linking pivot tables with VBA

  1. #1
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Linking pivot tables with VBA

    Hi all, I have 3 pivot tables with the same 3 "report filters" but each with different row and column labels.

    All pivot tabels are on teh same sheet (Sheet2), I would like to know how to change the pivot filter on the other 2 tables if I change the filter on the first.

    For instance, if I change the filter "Fruit" to bananas on pivot table 1, I would like the filters on pivot tables 2 and 3 to also change to bananas.

    Any help would be appreciated

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Linking pivot tables with VBA

    right click sheet tab and pick View Code.

    Paste the following in to the sheet code module.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Linking pivot tables with VBA

    Hi Andy, I get an error message which highlights the section "strCurrentPage = Target.PivotFields("Quarter").CurrentPage"

    The error message says run time error 1004, unable to get the pivotfields property of the pivot table class

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Linking pivot tables with VBA

    Did you change the name "Quarter" to what ever the pagefield in your pivot table is called, as it's the name I used for testing

  5. #5
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Linking pivot tables with VBA

    Hi Andy, what is the page field? I have changed quarter to both the current page name, and the data set page name and I get the same error

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Linking pivot tables with VBA

    pagefield is the thing that you are using to filter the pivot table, you called it 'report filters'.

    If still stuck post example workbook.

  7. #7
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Linking pivot tables with VBA

    Thanks Andy, works a treat

  8. #8
    Registered User
    Join Date
    01-11-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Linking pivot tables with VBA

    How would you do this if you are trying to link three pivot fields located on separate sheets?

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Linking pivot tables with VBA

    mmeier017,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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