+ Reply to Thread
Results 1 to 14 of 14

Reset pivot table fields in multiple sheets

  1. #1
    Forum Contributor
    Join Date
    05-26-2008
    Posts
    122

    Reset pivot table fields in multiple sheets

    hi all..

    i posted this originally in the general forum but i think vba is required for this so ill try here.. mods.. sorry if this counts as a repost.

    basically i have pivot tables in diff pages
    im trying to make a button to reset all the fields in all the pivot tables..

    i tried recording a macro to do this but it only works for page fields..
    it wont work for the column fields.. act, adopt and check are page fields at the top... region is a column field ... goto_AQcheck is a macro to switch to that sheet which is assigned to another button....

    this isthe code it gave:

    Please Login or Register  to view this content.
    i tried adding the following line to reset teh filter for the column field but it gives an error..

    Please Login or Register  to view this content.
    any ideas .. also i dont think this will be efficient for multiple sheets..
    any other ideas ? help is greatly appreciated.. thanks
    Last edited by rylo; 08-29-2008 at 12:15 AM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    1) Can you please remember to wrap your code. Makes things much easier to read.

    2) How about adding a loop
    Please Login or Register  to view this content.
    rylo

  3. #3
    Forum Contributor
    Join Date
    05-26-2008
    Posts
    122
    hey... sorry about that.. never posted code before .. now i know better

    i tried the loop.. it fails on the
    Please Login or Register  to view this content.
    Runtime error '1004'
    Unable to set the visible property of the PivotItem class


    also im not sure what your code is doing...
    im very new to vba so help is greatly appreciated..

    the thing is that region is a column field and i want it to reset to "ShowAll"

    lets forget about multiple sheets.. lets jus say theres one pivot table..
    how do you reset the column fields to "showAll"

    really appreciate the help

  4. #4
    Forum Contributor
    Join Date
    05-26-2008
    Posts
    122
    sorry my bad.. it is the row fields im trying to reset

  5. #5
    Forum Contributor
    Join Date
    05-26-2008
    Posts
    122
    Please Login or Register  to view this content.
    i foudn this code somewhere
    after u run the macro..it keeps looping
    you have to press escape and end to stop it
    but it works.. all the row fields get reset
    i guess it keeps looking for more pivot tables in the workbook

    any ideas ??

  6. #6
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Please Login or Register  to view this content.
    How about that?

    You can choose (lesser of two evils...) to display alerts or not - one way the thing will get all flustered if there is data in your sheet, the other way it will just overwrite it...

    HTH

    (Actually, this one's a keeper, think it will be quite handy - good idea!)

  7. #7
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Also, general notes; really good work on trying ="(Show all)" and the other bits you've posted - you're going to learn super fast using logical extrapolations like that and giving it a go.

    A tip for this kind of thing (cheesy mantra coming up) always use option explicit. Then define your variables as your write your code, that way, when you put a . at the end of one of these things, you get a whole host of "tips" on what to try next.

    That's how I worked out I didn't need to cycle through every item in every pivot field!

    HTH

  8. #8
    Forum Contributor
    Join Date
    05-26-2008
    Posts
    122
    thanks for the help but problem persists...


    Shouldnt the

    Please Login or Register  to view this content.
    be before the
    Please Login or Register  to view this content.
    it didnt work though.. same thing.. the cursor turns into a hour glass and eventually i have to use esc to break the loop

    if i choose debug .. the line
    Please Login or Register  to view this content.
    gets higghlted.. error says unable to setproperty showallitems

    :S
    Last edited by manny_cb; 08-29-2008 at 01:43 PM.

  9. #9
    Forum Contributor
    Join Date
    05-26-2008
    Posts
    122
    thanks for the pointers

  10. #10
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    have you not got a working solution? Not sure from your last post.

    If not, then attach an example workbook with your pivot table and code so we can review.

    rylo

  11. #11
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Worked for me although the pivot table I used to test it on was very simple (created for the job).

    I now use it as a handy "reset" tool for other pivot tables.

    RE: defining variables; again, worked for me - someone clever might step in and explain when's best to define variables in a macro and when to put them at the top of a module.

  12. #12
    Forum Contributor
    Join Date
    05-26-2008
    Posts
    122
    hey guys... thanks for all the help.. but still no working solution.. maybe ur solution didnt work cuz im in excel 2002 ??
    Attached Files Attached Files

  13. #13
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Try this:
    Please Login or Register  to view this content.
    I didn't test my first code thoroughly enough...

  14. #14
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Further to this (to clarify)
    showallitems doesn't show all items, it checks "show items with no data" - not what was asked for.

    looping through hiddenitems stops the macro crashing on the page fields at the top.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro/command button to reset all filters in pivot table
    By schueyisking in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-29-2008, 11:30 AM
  2. bug in vba macro to create pivot table
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-30-2008, 05:27 PM
  3. Sorting pivot table fields
    By jmeron in forum Excel General
    Replies: 1
    Last Post: 06-16-2008, 10:58 PM
  4. pivot Table -Calculated fields
    By sach0025 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-09-2007, 11:38 AM
  5. Help: Create Pivot Table from multiple tabs in a Spreadsheet
    By AUDIOBLASTER in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-04-2007, 12:30 PM

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