+ Reply to Thread
Results 1 to 12 of 12

Show/Hide Button

  1. #1
    Registered User
    Join Date
    02-17-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    6

    Show/Hide Button

    Im creating a dictionary in Exel and would like a show hide button. At the moment it works fine but my cells are static. I have a row titled B on row 7, and C on row 12. If I add a row in between then obviously the button wont work properly. How do I adjust the code below to say "show or hide all rows between "B" and "C"

    Private Sub CommandButton2_Click()
    Dim myRng As Range

    Set myRng = Me.Range("b8:b11")

    myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)
    End Sub

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Show/Hide Button

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    02-17-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Show/Hide Button

    Sorry! this my first post

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,062

    Re: Show/Hide Button

    hi,
    not sure if it helps you but just try it!
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  5. #5
    Registered User
    Join Date
    02-17-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Show/Hide Button

    Thanks John

    This one didnt work though

  6. #6
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,062

    Re: Show/Hide Button

    ah...sorry! I misunderstood!

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Show/Hide Button

    Please Login or Register  to view this content.



  8. #8
    Registered User
    Join Date
    02-17-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Show/Hide Button

    Hi snb
    That one still only hides the selected cells. I need to it search for the cells containing B and C, and hide everything in between

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Show/Hide Button

    It's rather confusing to use B and C for rows.
    Please Login or Register  to view this content.
    Why don't you post a sample workbook to illustrate your question ?

  10. #10
    Registered User
    Join Date
    02-17-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Show/Hide Button

    Attached is sample. As you can see, the button works now, but if you add a line between B and C, then it doesnt work anymore.
    Attached Files Attached Files

  11. #11
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Show/Hide Button

    If you empty the cells in which the commandbuttons reside this will suffice:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    02-17-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Show/Hide Button

    Thanks very much you are a star!

+ 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