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
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
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.
 
Upvote 0
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.
 
Upvote 0
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")
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,999
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top