+ Reply to Thread
Results 1 to 4 of 4

How do I make a command button invisible or visible?

  1. #1
    Mandora
    Guest

    How do I make a command button invisible or visible?

    I have two command buttons. One hides a range of columns with VB code. One
    unhides the same range with VB code. Due to space constraints I would like to
    have the 'hide" button set the visible property of that button to false and
    the "hide button" to true and visa-versa with the other button. By placing
    the buttons on top of each other the proper button is always visible and
    space used is compact. I am new to VB and can't get this to work although I
    assume it is possible. Suggestions?

  2. #2
    Guest

    How do I make a command button invisible or visible?

    hi,
    no need to do that. you can combine the show/hide in one
    button.
    here is some code i use. it only hide 1 column at a time
    but you can modify it to your needs. it also changes the
    button color and captions so that i can use the button as
    a header.(same more space)
    Private Sub CommandButton1_Click()
    ' hide/show column
    If Columns("L:L").Hidden = True Then
    Columns("K:K").Hidden = True
    Columns("L:L").Hidden = False
    CommandButton1.Caption = "inches"
    CommandButton1.BackColor = &HFF&
    Else
    Columns("K:K").Hidden = False
    Columns("L:L").Hidden = True
    CommandButton1.Caption = "cms"
    CommandButton1.BackColor = &HC000&
    End If
    End Sub
    >-----Original Message-----
    >I have two command buttons. One hides a range of columns

    with VB code. One
    >unhides the same range with VB code. Due to space

    constraints I would like to
    >have the 'hide" button set the visible property of that

    button to false and
    >the "hide button" to true and visa-versa with the other

    button. By placing
    >the buttons on top of each other the proper button is

    always visible and
    >space used is compact. I am new to VB and can't get this

    to work although I
    >assume it is possible. Suggestions?
    >.
    >


  3. #3
    Jim Thomlinson
    Guest

    RE: How do I make a command button invisible or visible?

    Here is some code to just change the caption on the button. Generally a
    better way to go. This assumes that the button that you got came off of the
    control toolbox, and you go into properties of that button and change the
    Name to cmdHide.

    Private Sub cmdHide_Click()
    If ActiveSheet.Range("A11:A14").EntireRow.Hidden = False Then
    ActiveSheet.Range("A11:A14").EntireRow.Hidden = True
    ActiveSheet.cmdHide.Caption = "Unhide"
    Else
    ActiveSheet.Range("A11:A14").EntireRow.Hidden = False
    ActiveSheet.cmdHide.Caption = "Hide"
    End If

    End Sub

    HTH

    "Mandora" wrote:

    > I have two command buttons. One hides a range of columns with VB code. One
    > unhides the same range with VB code. Due to space constraints I would like to
    > have the 'hide" button set the visible property of that button to false and
    > the "hide button" to true and visa-versa with the other button. By placing
    > the buttons on top of each other the proper button is always visible and
    > space used is compact. I am new to VB and can't get this to work although I
    > assume it is possible. Suggestions?


  4. #4
    Bob Phillips
    Guest

    Re: How do I make a command button invisible or visible?

    Private Sub cmdHide_Click()
    With Me
    .cmdHide.Visible = False
    .cmdUnhide.Visible = True
    .cmdDo1.Visible = False
    End With
    End Sub


    Private Sub cmdUnhide_Click()
    With Me
    .cmdHide.Visible = True
    .cmdUnhide.Visible = False
    .cmdDo1.Visible = True
    End With
    End Sub



    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Mandora" <[email protected]> wrote in message
    news:[email protected]...
    > I have two command buttons. One hides a range of columns with VB code. One
    > unhides the same range with VB code. Due to space constraints I would like

    to
    > have the 'hide" button set the visible property of that button to false

    and
    > the "hide button" to true and visa-versa with the other button. By placing
    > the buttons on top of each other the proper button is always visible and
    > space used is compact. I am new to VB and can't get this to work although

    I
    > assume it is possible. Suggestions?




+ 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