Results 1 to 4 of 4

Thread: Toggle button Macro
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Apr 2017
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Toggle button Macro

    Hi,

    Below is some VBA code used with a toggle button to hide/unhide rows 8:10. This works perfectly.

    I need to amend the code so the button hides/unhides rows 16,22,23,26,30,32,46,49,52,55,58 AND Columns G,H,I,J.

    Private Sub ToggleButton1_Click()
    Dim xAddress As String
    xAddress = "8:10"
    If ToggleButton1.Value Then
    Application.ActiveSheet.Rows(xAddress).Hidden = True
    ToggleButton1.Caption = "Show Scenario"
    Else
    Application.ActiveSheet.Rows(xAddress).Hidden = False
    ToggleButton1.Caption = "Hide Scenario"
    End If
    End Sub

    Thanks in advance.

  2. #2
    Board Regular
    Join Date
    Jul 2012
    Location
    Hampshire, UK
    Posts
    5,032
    Post Thanks / Like
    Mentioned
    26 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Toggle button Macro

    Hi,
    untested

    Code:
    Private Sub ToggleButton1_Click()
        Range("G:J").EntireColumn.Hidden = ToggleButton1.Value
        Range("8:10,16:16,22:23,26:26,30:30,32:32,46:46,49:49,52:52,55:55,58:58").EntireRow.Hidden = ToggleButton1.Value
        ToggleButton1.Caption = IIf(ToggleButton1.Value, "Show Scenario", "Hide Scenario")
    End Sub
    Dave

  3. #3
    New Member
    Join Date
    Apr 2017
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Toggle button Macro

    Brilliant, Thanks Dave.

    Works well

  4. #4
    Board Regular
    Join Date
    Jul 2012
    Location
    Hampshire, UK
    Posts
    5,032
    Post Thanks / Like
    Mentioned
    26 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Toggle button Macro

    Quote Originally Posted by gobblechops View Post
    Brilliant, Thanks Dave.

    Works well
    welcome - many thanks for feedback

    Dave

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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