Closed Thread
Results 1 to 11 of 11

Excel 2007 : Change Multiple Page Fields Simultaneously in Pivot Tables

  1. #1
    Registered User
    Join Date
    05-14-2010
    Location
    serbia
    MS-Off Ver
    Excel 2007
    Posts
    27

    Change Multiple Page Fields Simultaneously in Pivot Tables

    Hello everyone !

    I have a problem with pivot tables in Excel 2007.

    There are 4 pivot tables on 2 sheets, all made from same source table (after I made first one I copied it and changed the parameters I needed).

    I'd like to change filters in page fields simultaneously on all 4 tables. Ie. when I change page field filter on the first one I'd like to have page fields changed on other 3 pivot tables.

    I found some solutions here: http://www.contextures.com/excelfiles.html#Pivot

    However when I tried to apply solutions in templates PT0021 - Change All Page Fields and PT0008 - Change Multiple Page Fields , they just wouldn't work. Moreover, I can't even make original templates to work. This also happens with the other files and macros I downloaded (and they all have more or less similar approach )

    I know they are macro-enabled files so I enabled macros in Excel (and developer tab and whatnot) but that didn't help.

    There is obviously something I am doing wrong or not doing at all or there is something else I should enable in order to make macros in templates to work..
    I guess if I can make template files work I could use them for my pivot tables.

    Any help or idea is appreciated.

    eriol
    Last edited by eriol; 05-15-2010 at 12:38 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Change Multiple Page Fields Simultaneously in Pivot Tables

    The code in the link below is specific to Pivots created in XL2007 and beyond*:

    http://www.excelforum.com/2155223-post20.html

    The code should be placed within ThisWorkbook in VBE

    The array vFields should contain the names of those Page Fields common to each Pivot that are to be altered simultaneously.

    Without a file it's hard to give any more specific advice I'm afraid - hopefully the above will do what you want.

    *pivots created pre XL2007 handle multi select Page fields differently (the process for iterating selected items within the Page field is very different in earlier versions)

  3. #3
    Registered User
    Join Date
    05-14-2010
    Location
    serbia
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: Change Multiple Page Fields Simultaneously in Pivot Tables

    Thank you Very Much for your swift answer. It works great !

    However is it possible to make it work for pivot tables in both worksheets, so far it works changes everything but only on first sheet ?

    thx again,

    eriol

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Change Multiple Page Fields Simultaneously in Pivot Tables

    Assuming you have no Pivots to be excluded from this process then first add an additional variable declaration:

    Please Login or Register  to view this content.
    The modify the main iteration to:

    Please Login or Register  to view this content.
    (in short the first and last lines are new - the 2nd line is modified to use ws rather than ActiveSheet)

  5. #5
    Registered User
    Join Date
    05-14-2010
    Location
    serbia
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: Change Multiple Page Fields Simultaneously in Pivot Tables

    Tank you for your time. I am so-and-so with VBA (in fact, little more then total beginner). Ichanged it in to this:

    Please Login or Register  to view this content.
    Now, it changes fields on both tables on first sheet and second table on second sheet. But I'll check if there is something different with that table.

    Again, I appreciate all the time you put in to this.

    eriol

  6. #6
    Registered User
    Join Date
    05-14-2010
    Location
    serbia
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: Change Multiple Page Fields Simultaneously in Pivot Tables

    I tried different approaches but I can`t make all pivot tables to update. For some reason when I change page fields on table 1 in sheet "pivot 1", pivot tables 1,2, and 4 update but not number 3.(and when I update table on sheet "pivot 2" it misses the table from "pivot 1"

    I copied the code in the sheet "pivot 1" because when I put it in ThisWorkbook nothing happens.

    Also I saved the workbook as .xlsm

    I put the file in the attachment so you can see what I am talking about.

    regards, eriol
    Attached Files Attached Files

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Change Multiple Page Fields Simultaneously in Pivot Tables

    My bad... I was in a rush when I replied last time.

    The code below should reside in ThisWorkbook and should replace all other code already in place
    (ie remove existing code from ThisWorkbook and from the Sheet1 object in VBE)

    I've also changed the order of the iteration.

    Please Login or Register  to view this content.
    Again, the above is coded for Pivots created in XL2007 and beyond.

  8. #8
    Registered User
    Join Date
    05-14-2010
    Location
    serbia
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: Change Multiple Page Fields Simultaneously in Pivot Tables

    Works Perfectly !

    Much Thanx for your help. Could've never done it without it.

    Best Regards, eriol

  9. #9
    Registered User
    Join Date
    06-18-2010
    Location
    Reeuwijk, The Netherlands
    MS-Off Ver
    Excel 2003, 2007 and 2010
    Posts
    1

    Thumbs up Re: Change Multiple Page Fields Simultaneously in Pivot Tables

    Hi Eriol, DonkeyOte

    This is way cool! Thanks for starting this thread. It is exactly what I am looking for. Of course now I have a challenging additional request:

    How would you make it so that I would make the pivot table (by pressing a button or something like that) run through all different possible values of the page filters and create a pivot table for each of the different values in the filter in a different worksheet?

    DonkeyOte, I hope you can fix this one too :-)

    Thanks,

    Maurik

  10. #10
    Registered User
    Join Date
    06-13-2012
    Location
    athens
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Change Multiple Page Fields Simultaneously in Pivot Tables

    Hi,
    I 'd like to ask if I can do the same thing (Change Multiple Page Fields Simultaneously in Pivot Tables) but when i select an item in the first pivot table's page fields, i want page fields for the other pivot tables to change not to the same item but to another item (that I can define through a excel formula). Is that possible?

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

    Re: Change Multiple Page Fields Simultaneously in Pivot Tables

    Johnnylzep,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    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]

Closed 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