• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Hide only CommandButtons

S P P

Member
This VBA hides all userform controls

How to hide only CommandButtons

>>> use code - tags <<<
Code:
Dim Ctl As Control
For Each Ctl In Me.Controls
Ctl.Visible = false
Next Ctl
 
Last edited by a moderator:
try:
Code:
Dim Ctl As Control
For Each Ctl In Me.Controls
    If TypeName(Ctl) = "CommandButton" Then Ctl.Visible = False
Next Ctl
 
p45cal

Thanks again

How to keep a CommandButton Visible

CommandButton10

I forgot that the Exit CommandButton must remain Visible
 
Either of the lines in the middle:
Code:
Dim Ctl As Control
For Each Ctl In Me.Controls
  If TypeName(Ctl) = "CommandButton" Then
    If Not CommandButton10 Is Ctl Then Ctl.Visible = False 'or:
    'If Ctl.Name <> "CommandButton10" Then Ctl.Visible = False
  End If
Next Ctl
 
Back
Top