Hiding multiple commandbuttons

TaskyFuji

New Member
Joined
Dec 19, 2020
Messages
7
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Good morning,

I'd like to ask help to hide multiple commandbuttons. They have different actions and it's a step by step process. So some steps I need to hide multiple command buttons using another commandbutton. I also renamed these commandbuttons (ex. Yes 1, No_1, Backto1). Would deeply appreciate your help. Thanks!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hello TaskyFuji,
if your buttons are all on the userform try this...
VBA Code:
Private Sub CommandButton1_Click()
    
    Dim vCtrl As Control
    
    With Me
        For Each vCtrl In .Controls
            If Not vCtrl.Name = .ActiveControl.Name And _
                TypeName(vCtrl) = "CommandButton" Then
                vCtrl.Visible = False
            End If
        Next vCtrl
    End With
    
End Sub
 
Upvote 0
If those CommandButtons are in a "group" without any intervening controls between them, then place a Frame control on the UserForm, put the Command Buttons in the Frame (Cut/Paste them into the Frame), then move the Frame into position, align the CommandButtons as needed and then in the Frame's Property window, delete the Caption, set the BackColor equal to the UserForm's BackColor and change the SpecialEffect property to Flat. After all that is done, one line of code is all you will need then... simply set the Frame's Visible property to False and all the CommandButtons on it will disappear... setting its Visible property back to True will make the CommandButtons all reappear.
 
Upvote 0

Forum statistics

Threads
1,215,047
Messages
6,122,858
Members
449,096
Latest member
Erald

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