S S P P Member Aug 27, 2021 #1 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: Aug 27, 2021
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
p45cal Well-Known Member Aug 27, 2021 #2 try: Code: Dim Ctl As Control For Each Ctl In Me.Controls If TypeName(Ctl) = "CommandButton" Then Ctl.Visible = False Next Ctl
try: Code: Dim Ctl As Control For Each Ctl In Me.Controls If TypeName(Ctl) = "CommandButton" Then Ctl.Visible = False Next Ctl
S S P P Member Aug 27, 2021 #3 p45cal Thanks again How to keep a CommandButton Visible CommandButton10 I forgot that the Exit CommandButton must remain Visible
p45cal Thanks again How to keep a CommandButton Visible CommandButton10 I forgot that the Exit CommandButton must remain Visible
p45cal Well-Known Member Aug 27, 2021 #4 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
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