+ Reply to Thread
Results 1 to 11 of 11

expand and collapse across multiple sheets with one control

  1. #1
    Registered User
    Join Date
    10-31-2006
    Posts
    61

    expand and collapse across multiple sheets with one control

    Hi,

    I have a workbook with ~15 sheets (and growing) in it, all of a varying number or rows. In column A I could always put an IF statement that if there is data in a particular cell, return "filled" and then manually filter to only show the "filled" rows, however I was wondering if there is a way to have one "toggle" (if that is the correct word) on one master sheet that would collapse all those empty rows? I have attached a simplistic example where I would like to automate the filtering in cell A1. Not sure if a macro is the tool, or if there is another solution. I have only begun to explore macros so my knowledge is very limited.

    Any assistance is greatly appreciated.

    Thanks,

    Chris
    Attached Files Attached Files
    Last edited by waternut; 10-02-2015 at 10:32 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: expand and collapse across multiple sheets with one control

    Copy the following code into a standard module. Add a button on the MASTER sheet and assign the macro to it.

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-31-2006
    Posts
    61

    Re: expand and collapse across multiple sheets with one control

    TMS, thank you very much, that worked perfectly!!!!!

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: expand and collapse across multiple sheets with one control

    You're welcome.


    Note that this routine uses actual blank cells in column B rather than the text "FILLED" in column A. From that perspective, column A is redundant. You could also do something similar by switching on and off the AutoFilter on column B. Again, no need for column A.

    Please Login or Register  to view this content.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    10-31-2006
    Posts
    61

    Re: expand and collapse across multiple sheets with one control

    Hi,

    Now that I have tried to implement this, I am having a run time error '1004': No cells were found. Which I think is coming up because I had to end up creating a formula in the column being evaluated. The formula is IF((COUNTIFS(I4:J4,">0")+COUNTIFS(I4:J4,"<0"))=0,"","X")which I need because I have some rows where the values negate each other, however I still want them to be displayed, such as $10 and -$10. Now that I have this formula in there, is there a way the original macro can be modified to account for the formula? TMS, in your last post I understand what you mean regarding the "FILLED" text in column A. I only did that in the original example to demonstrate what I has hoping I could get a macro to do for me.

    I tried implementing the second macro, however I am not sure how to use it. After putting it into a module do I utilize the auto filtering on one sheet to expand and collapse the rows on every sheet, or do I need something else to make it work. All options and thoughts are appreciated.


    Thanks,

    Chris

  6. #6
    Registered User
    Join Date
    10-31-2006
    Posts
    61

    Re: expand and collapse across multiple sheets with one control

    BUMP to the top

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: expand and collapse across multiple sheets with one control

    Please Login or Register  to view this content.

    Regards, TMS

  8. #8
    Registered User
    Join Date
    10-31-2006
    Posts
    61

    Re: expand and collapse across multiple sheets with one control

    A couple last questions, how would l modify this if instead of excluding the sheet named "MASTER" I wanted it to include only certain sheets, lets call them "SHEETS1" "SHEETS2" "SHEETS3" ?

    Also in the above the macro appears to be keying off of a formula in column A to expand and collapse the rows, how would I alter it if the formula was say in row "F"?

    Lastly what does
    Please Login or Register  to view this content.
    do as part of the macro? sorry for the newbie questions.

    Chris

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: expand and collapse across multiple sheets with one control

    You're welcome. Thanks for the rep.

    Point of note for future reference: it's always best to ask the question you want answering, not a hypothetical question with a sample workbook that doesn't reflect the live environment.

    To be selective about the sheets, use
    Please Login or Register  to view this content.
    To filter on column F, use:
    Please Login or Register  to view this content.
    The code:
    Please Login or Register  to view this content.
    just determines the last row of data. It's equivalent to selecting the last/bottom row on the spreadsheet and pressing End followed by Up-arrow and looking at the row of the cell selected. In this instance it is based on column B as that is the column that is populated with a formula.

    The revised code would look like this:

    Please Login or Register  to view this content.

    Regards, TMS

  10. #10
    Registered User
    Join Date
    10-31-2006
    Posts
    61

    Re: expand and collapse across multiple sheets with one control

    Hi TMS,

    Thanks for all the help and my apologies for having to modify things as I went along. Typically I can post an example data set that replicates what I am after. In this case, it changed on me after the original posting, and I am unfortunately limited to these example files, as some of my data sets are sensitive and not available to be posted publicly. All that said I really appreciate your insight assistance and learning about macros.

    Thanks.

    Chris

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: expand and collapse across multiple sheets with one control

    You're welcome.

+ 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] Multiple macros that collapse and expand different columns
    By jcs2811 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-25-2020, 05:03 AM
  2. Multiple Collapse/Expand - Pivot Table Field List
    By pattyjay in forum Excel General
    Replies: 2
    Last Post: 09-17-2015, 04:37 PM
  3. VBA to expand & collapse multiple pivot tables at the same time
    By jrg72982 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2014, 06:12 PM
  4. Expand and Collapse Multiple OLAP Pivots in the same sheet.
    By aeropostale in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-13-2012, 09:50 AM
  5. Expand & Collapse Pivot Tables in multiple worksheets
    By kaseyleigh in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 12-12-2012, 09:57 AM
  6. How can I Collapse or Expand Outline in Protected Sheets
    By Gos-C in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-20-2006, 08:16 PM
  7. how can i collapse and expand colums
    By JVICO in forum Excel General
    Replies: 1
    Last Post: 04-20-2006, 09:10 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