+ Reply to Thread
Results 1 to 10 of 10

Macro/command button to reset all filters in pivot table

  1. #1
    Registered User
    Join Date
    07-30-2008
    Location
    UK
    Posts
    52

    Macro/command button to reset all filters in pivot table

    hi there,

    i have a pivot table with over 4000 entries and about 12 columns which i filter to get the info i want.

    Unfortunately with so many rows and columns in the table, if i do a macro that gets each filter back to 'show all' its really slow.

    Doing this manually using the "Show all" option in the filter takes a fraction of a second, so surely there must be a way to do this more quickly in VBA?

    i can't understand why manually it takes no time at all, but automating it through recording a macro takes forever.

  2. #2
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848
    What does your code look like?


    Using the macro recorder, I got the following code when I remove the filters. The Field:=# is sequenced from left to right. I received no error message if the filter was not on for that particular field.
    Please Login or Register  to view this content.
    Last edited by mdbct; 08-25-2008 at 10:53 PM.

  3. #3
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848
    Many many apologies. I misread your post - I thought you were using the auto filter. My original question still stands - what does your code look like?

    One thing you may want to try is to surround your code like so...

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-30-2008
    Location
    UK
    Posts
    52
    hi,

    thanks for the response.
    Below is what the macro looks like.

    Please Login or Register  to view this content.
    As you can see its massive, i actually had to delete 40% of it to fit it in this post, so you can see why it takes so long, because i guess its individually 'ticking the box' of every single field in the 8 odd columns i want it to 'show all' for in the pivot table.

    When I run it, if i left it to complete the macro, it would probably take hours, i just have to stop the action by pressing escape. Surely theres a better solution to get it to 'show all', as i say, if when done manually it only takes a few seconds per column? I don't understand why it isn't recording the process behind when you do it manually, instead of doing what it's doing (the code above).

  5. #5
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848
    Try wrapping the code in the

    Please Login or Register  to view this content.
    I ran again a very small pivot table using the recorded macro and it took about two seconds to run the macro and I was restoring only 8 items. With the Application.ScreenUpdatings it was instantaneous results.

  6. #6
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848
    I forgot to ask, what version of Excel are you using? I've been testing on 2000 which doesn't have a Show All options for the filters.

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    http://www.contextures.com/xlPivot03.html
    vba should still work on later excel versions

  8. #8
    Registered User
    Join Date
    07-30-2008
    Location
    UK
    Posts
    52
    i tried 'wrapping' the code as you suggested, didn't seem to work for me, clearly doing something wrong.

    How do i wrap the code that i posted on here with that application screen updating thing i.e. where abouts does it go exactly?

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    after sub() and before end sub

  10. #10
    Forum Contributor
    Join Date
    05-26-2008
    Posts
    122
    i had the same issue.. it selects each entry as a separate check.. iot wont do a show all.. have u solved this problem yet?

+ 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. Pivot Table - Few complicated queries
    By acsishere in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-04-2008, 05:08 PM
  2. hierarchy filters in pivot table
    By yossiybi in forum Excel General
    Replies: 5
    Last Post: 07-13-2008, 09:55 AM
  3. hierarchy between filters in pivot table
    By yossiybi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-06-2008, 06:26 AM
  4. Reset defaul pivot table names
    By esreyes in forum Excel General
    Replies: 1
    Last Post: 10-01-2007, 12:47 PM
  5. a pivot table report cannot overlap another pivot table report
    By judyh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-25-2007, 12:59 AM

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