+ Reply to Thread
Results 1 to 7 of 7

Hide/Unhide with auto-changing object

  1. #1
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    807

    Hide/Unhide with auto-changing object

    I'm working my way through module Programming in VBA 1.01 so this is way beyond me:-

    I have an Excel schedule with subtotals and between 1 and 50 rows under each subtotals. The subtotals contain totals of the rows below them. Is it possible to link code to an object (say a 'down arrow' next to each subtotal) and when it is hit, it unhides the rows beneath the subtotals? At the same time the 'down arrow' changes to an 'up arrow' and when that it hit it re-hides the rows.

    There is also the possibility that the user will unhide rows and move down the spreadsheet unhiding/rehiding other areas before coming back and wanting to re-hide the first area he revealed. When the spreadsheet is closed, all the arrows should revert to 'down arrows' and all the non-subtotals' rows should be hidden.

    Does this make any sense?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide/Unhide with auto-changing object

    Hello BrisbaneBob,

    Is this a project you were given for a class? It can be done, but it is quite complex. Do you have a sample workbook you can post?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    807

    Re: Hide/Unhide with auto-changing object

    Hi Leith

    I wish it was a project - I'd take a fail quite happily.

    I have 500 line financial report with subtotals (as per attached sample). I didn't think it would be simple when I started (yesterday) trying to do it but I had no idea how complicated it was going to be - well past my level of knowledge. But it sounds so easy in principle....!

    If you have any ideas I'd be grateful.

    Thanks and regards
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide/Unhide with auto-changing object

    Hello BrisbaneBob,

    Turn out to be easier than I had first thought. Each arrow has a macro assigned to it. Each macro call another macro that does the work. The macro assigned to arrow just passes the rows you want to hide. The macro below are already added to the attached workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    807

    Re: Hide/Unhide with auto-changing object

    Leith

    Brilliant! BRILLAINT!

    Where in the code does the arrow change direction? I can't work that bit out.

  6. #6
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    807

    Re: Hide/Unhide with auto-changing object

    OK, OK - just opened my eyes and saw 'rotation'

    Thanks very much - a great solution.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide/Unhide with auto-changing object

    Hello BrisbaneBob,

    The Arrow is flipped by the If Then Else statement in the HideRows macro. Status is the negation of the of the hidden property. When the rows are visible, Status will be false and the arrow is not rotated (pointing up), if Status is True then the arrow is flipped 180 degrees (pointing down).

+ Reply to 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