+ Reply to Thread
Results 1 to 5 of 5

Toggle Button

  1. #1
    Registered User
    Join Date
    02-09-2005
    Posts
    32

    Question Toggle Button

    Hi all,

    I am looking a putting a VB command button on one of my sheets, which when pressed once it does one thing, then when pressed again it does something different.

    e.g. when pressed first time it hides a range of rows, when pressed again it unhides them.

    Hope you can help

    Dave

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning Dave_2k5

    Why not set up a check box from the control toolbox toolbar. Once you've drawn it on screen double click on it and paste the code below into the window that opens. Close the window to return to Excel and on the Control Toolbox bar select Design Mode (top left) to set the checkbox.

    The code shown assumes that your checkbox will be called Checkbox1 and that you want to hide rows 10 to 15 inclusive.

    Private Sub CheckBox1_Click()
    If CheckBox1.Value = True Then
    Rows("10:15").EntireRow.Hidden = True
    Else
    Rows("10:15").EntireRow.Hidden = False
    End If
    End Sub

    HTH

    DominicB

  3. #3
    Registered User
    Join Date
    02-09-2005
    Posts
    32
    I would do that......But want it to be a button not a checkbox!!

    Cheers Anyway

    Dave

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi Dave

    If it HAS to be a button then have a look in the control toolbox - there is a toggle button. Don't use the forms toolbar because there isn't one there.

    HTH

    DominicB

  5. #5
    William
    Guest

    Re: Toggle Button

    Hi Dave

    Range("F12:F46").EntireRow.Hidden = _
    Not Range("F12:F46").EntireRow.Hidden

    --


    XL2003
    Regards

    William
    [email protected]


    "Dave_2k5" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi all,
    >
    > I am looking a putting a VB command button on one of my sheets, which
    > when pressed once it does one thing, then when pressed again it does
    > something different.
    >
    > e.g. when pressed first time it hides a range of rows, when pressed
    > again it unhides them.
    >
    > Hope you can help
    >
    > Dave
    >
    >
    > --
    > Dave_2k5
    > ------------------------------------------------------------------------
    > Dave_2k5's Profile:
    > http://www.excelforum.com/member.php...o&userid=19667
    > View this thread: http://www.excelforum.com/showthread...hreadid=401061
    >





+ 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