+ Reply to Thread
Results 1 to 8 of 8

Hide/unhide cells when expanding/collapsing pivot table fields

  1. #1
    Registered User
    Join Date
    07-05-2013
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    6

    Hide/unhide cells when expanding/collapsing pivot table fields

    Hi everyone,

    So I spent a couple of days searching for an answer, but I've had no luck so far. I am working on a dashboard and have a few pivot tables one right on top of the other. I have enough rows hidden between them so that I don't get the pivot tables cannot overlap another error, but the code I'm using seems inefficient. I want the rows to unhide when they become populated with data, ie after I expand a field, and hide the rows when they are empty.

    Here is the code I am currently using.
    Please Login or Register  to view this content.
    The problem is that every time I expand or collapse a field the for loop checks through all of the cells and can take a couple seconds, which does not seem user friendly for the people who read the report. I am trying to figure out how to exit out of the for loop when it unhides the necessary amount of rows, ie. if I expand a field and it populates 10 cells with data, then I want the macro to unhide the 10 cells and then stop. When I collapse a field I want the macro to hide the cells that no longer have any data in them and then stop the for loop there without looping through all 84 rows.

    I hope this is enough information. Please let me know if other details are required.

    Thank you!

  2. #2
    Registered User
    Join Date
    07-05-2013
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Hide/unhide cells when expanding/collapsing pivot table fields

    bump 10char

  3. #3
    Registered User
    Join Date
    07-05-2013
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Hide/unhide cells when expanding/collapsing pivot table fields

    bump 10char

  4. #4
    Registered User
    Join Date
    01-14-2004
    Location
    Va Beach, VA
    Posts
    71

    Re: Hide/unhide cells when expanding/collapsing pivot table fields

    You can put this code in your worksheet
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-05-2013
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Hide/unhide cells when expanding/collapsing pivot table fields

    Awesome, this works perfectly. Thank you jimrosser!

  6. #6
    Registered User
    Join Date
    07-05-2013
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Hide/unhide cells when expanding/collapsing pivot table fields

    Ah, one question. How would I go about implementing this to work on multiple pivot tables on my worksheet. Say I have 2 pivot tables on the top row and two on the bottom.

  7. #7
    Registered User
    Join Date
    01-14-2004
    Location
    Va Beach, VA
    Posts
    71

    Re: Hide/unhide cells when expanding/collapsing pivot table fields

    Not sure I'm following you.
    But you could paste the code below and change the parameters.

  8. #8
    Registered User
    Join Date
    01-14-2004
    Location
    Va Beach, VA
    Posts
    71

    Re: Hide/unhide cells when expanding/collapsing pivot table fields

    Charliee,

    You may want to change your event code from
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    This should will make your sheet work faster.

+ 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. [SOLVED] undesirable change of cells color when expanding/collapsing pivot table
    By ivansamsonov in forum Excel Charting & Pivots
    Replies: 14
    Last Post: 05-28-2013, 09:34 AM
  2. collapsing/expanding pivot table fields in excel 2003
    By bcn1988 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-20-2013, 11:52 AM
  3. expanding/collapsing details in pivot table and scatterplot
    By woontime in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-28-2011, 09:22 PM
  4. Replies: 1
    Last Post: 04-25-2011, 01:17 PM
  5. hide/unhide a column when a pivot table in a new workbook is refreshed.
    By ronanm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-23-2011, 03:24 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