Button show hide on load of excel

mmittal

New Member
Joined
Aug 1, 2019
Messages
5
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
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Steve_

Board Regular
Joined
Apr 28, 2010
Messages
167
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.
 

mmittal

New Member
Joined
Aug 1, 2019
Messages
5
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.
 

mmittal

New Member
Joined
Aug 1, 2019
Messages
5
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")
 

Forum statistics

Threads
1,089,392
Messages
5,407,974
Members
403,174
Latest member
Zaibass

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...
Top