+ Reply to Thread
Results 1 to 12 of 12

Toggle Button to hide/unhide rows based on value

  1. #1
    Registered User
    Join Date
    04-18-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    37

    Toggle Button to hide/unhide rows based on value

    Hi,

    In column S I have reference cells which return 3 values: "ToggleTrue", "ToggleFalse", and "Hideme". Based on input from another Workbook, these reference cell values change from day to day. What I would like is for a toggle button to show either all rows with "ToggleTrue" or "ToggleFalse". However, I would also like the "Hideme" rows to never be shown whether the toggle button is pressed or unpressed.

    Does anybody know how to write code for this? Many thanks for some input!

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Toggle Button to hide/unhide rows based on value

    Hello goomblar,

    It will all depend on how your Code is structured within that Workbook. To help us not guessing what your setup looks like could you please, attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Toggle Button to hide/unhide rows based on value

    You should have posted a sample spreadsheet.

    I had to create my own

    Three macros are involved

    Two Sheet Specific and One Normal

    One macro runs when the sheet is activated to hide the hideme columns
    Another handles the checkbox event
    and finaly the standard macro hides the rows


    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mehmetcik; 10-02-2014 at 06:19 AM.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Toggle Button to hide/unhide rows based on value

    It just occurred to mre that the worksheet activate macro would be more effective if it were modified to:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Toggle Button to hide/unhide rows based on value

    Maybe:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-18-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Toggle Button to hide/unhide rows based on value

    Hi All,

    Thank you for your informative responses. For all intents and purposes, mehmetcik's attachment works. However, it is necessary that a toggle button is utilized. As requested, I've attached an example file that will hopefully clear things up a bit. I should point out that it is purely manually explained; There is no code or reference cells in the file.

    JOHN H. DAVIS - I just saw your post now so I will take a look at it and get back to you.

    EDIT: I should also point out that I need this for a limited range, not an infinite amount of rows. In the attachment, you can see that this range is for S5:S28
    Last edited by goomblar; 10-02-2014 at 10:18 AM.

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Toggle Button to hide/unhide rows based on value

    Modified:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-18-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Toggle Button to hide/unhide rows based on value

    Hi JOHN H. DAVIS,

    Thanks for the fast reply; your code works splendidly on my Workbook. However, when a value in column S is changed from, say, ToggleTrue to ToggleFalse, the toggle button no longer works properly.

    The reference cells will be updated various times in a day/week, and the toggle parameters need to take that into account. Any thoughts?

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Toggle Button to hide/unhide rows based on value

    How does it not work properly? What happens?

  10. #10
    Registered User
    Join Date
    04-18-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Toggle Button to hide/unhide rows based on value

    I've tried it again and I had just inputted it incorrectly - It works perfectly fine. Thank you!

    If I could request one additional thing... In order to input this into the more complex file that will actually be used, the parameters are as such actually S9:S48.

    How would I change the code to make this work? I've tried it myself and it for some reason freezes after running on all rows, not just the specified range. (I admit I am quite poor at VBA...)

  11. #11
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Toggle Button to hide/unhide rows based on value

    Try this version.

    I have pared it down a bit

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by mehmetcik; 10-03-2014 at 07:19 AM.

  12. #12
    Registered User
    Join Date
    04-18-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Toggle Button to hide/unhide rows based on value

    mehmetcik,

    Your solution has completely solved this issue, and seems to be working fine on my real file.

    Just to clarify what issues had persisted with JOHN H. DAVIS' code:
    1. When ToggleTrue was the first value, it no longer toggled between the two values. It only showed ToggleTrue.
    2. When ToggleFalse was the only value for the whole range, the workbook froze after running endlessly.

    I will play around with your code some more and if I encounter anything else I will come back. MANY thanks for everyone's support here.

+ 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] Macro to toggle between hide/unhide rows
    By fpt264 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2014, 04:30 PM
  2. button to toggle hide/unhide columns
    By dbuff in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-03-2013, 07:56 PM
  3. Hide/Unhide Multiple Sets of Columns with Toggle Button
    By Mischief433 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-06-2012, 05:55 AM
  4. Using Toggle Button to hide/unhide rows that may change
    By jmpatrick in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2011, 09:48 AM
  5. How to HIDE/UNHIDE Specific Sheets Using a TOGGLE Button?
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-16-2011, 02:58 AM

Tags for this Thread

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