Results 1 to 4 of 4

Thread: Button show hide on load of excel

  1. #1
    New Member
    Join Date
    Aug 2019
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Button show hide on load of excel

    Hi,

    I have an excel file with 5 buttons and each of them has a separate vba module but I want to display only one button on load of an excel. Other 4 buttons should load on click of the fifth button which was visible.

    Can anybody please guide me how to get this thing done?


    Thank you

  2. #2
    Board Regular
    Join Date
    Apr 2010
    Posts
    167
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Button show hide on load of excel

    Quote Originally Posted by mmittal View Post
    Hi,

    I have an excel file with 5 buttons and each of them has a separate vba module but I want to display only one button on load of an excel. Other 4 buttons should load on click of the fifth button which was visible.

    Can anybody please guide me how to get this thing done?


    Thank you

    Create a form. Put two buttons on it. Paste this code...

    Code:
    Private Sub CommandButton1_Click()
        CommandButton1.Visible = False
        'CommandButton1.enabled = False   ' This is useful too.
        CommandButton2.Visible = True
        ''CommandButton2.enabled = true
    End Sub
    Private Sub CommandButton2_Click()
        CommandButton1.Visible = True
        'CommandButton1.enabled = true   ' This is useful too.
        CommandButton2.Visible = False
        ''CommandButton2.enabled = false
    End Sub

    That should get you going.

  3. #3
    New Member
    Join Date
    Aug 2019
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Button show hide on load of excel

    Thanks Steve. I'm new to vba so I may be wrong. I already have an excel sheet and that sheet has some buttons. Those are buttons not the command buttons. When I enter your code, I get debug thing.

  4. #4
    New Member
    Join Date
    Aug 2019
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Button show hide on load of excel

    Quote Originally Posted by mmittal View Post
    Thanks Steve. I'm new to vba so I may be wrong. I already have an excel sheet and that sheet has some buttons. Those are buttons not the command buttons. When I enter your code, I get debug thing.
    I got this with the following code:
    Dim shp As Shape
    Set shp = ThisWorkbook.Worksheets("Sheet1").Shapes("Button 3")

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
  •