Consulting

Results 1 to 3 of 3

Thread: Toggle to Hide Rows

  1. #1
    VBAX Regular
    Joined
    Dec 2016
    Posts
    10
    Location

    Toggle to Hide Rows

    Hi All,

    Thanks in advance for your help. I hope this will be fairly easy, but I have spent quite a bit of time on this, and I couldn't quite get it.

    I need a Toggle code that if I click on it, rows 8:126 will be hidden no matter their value and the rest of the rows will be shown. And if I click again, rows 128:129 will be hidden no matter their value and the rest of the rows will be shown.

    Thanks again,

    Rob

  2. #2
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    Add a ToggleButton to your sheet and put the following code in
    Private Sub ToggleButton1_Click()
        Select Case Rows("8:126").Hidden
            Case True
                Rows("128:129").Hidden = True
                Rows("8:126").Hidden = False
                Me.ToggleButton1.Caption = "128 - 129 Hidden"
            
            Case False
                Rows("8:126").Hidden = True
                Rows("128:129").Hidden = False
                Me.ToggleButton1.Caption = "8 - 126 Hidden"
        End Select
    End Sub

  3. #3
    VBAX Regular
    Joined
    Dec 2016
    Posts
    10
    Location
    This is perfect. Thank you so much



    Quote Originally Posted by JKwan View Post
    Add a ToggleButton to your sheet and put the following code in
    Private Sub ToggleButton1_Click()
        Select Case Rows("8:126").Hidden
            Case True
                Rows("128:129").Hidden = True
                Rows("8:126").Hidden = False
                Me.ToggleButton1.Caption = "128 - 129 Hidden"
            
            Case False
                Rows("8:126").Hidden = True
                Rows("128:129").Hidden = False
                Me.ToggleButton1.Caption = "8 - 126 Hidden"
        End Select
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •