Userform Controls

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a userform with 26 Labels, 13 TextBoxes and 2 CommandButtons. What I
want to know is if there is a loop code to loop through each control
regaurdless of it's type and set Enable to False according to the Controls
name? I have the Labels and TextBoxes named Cntrl1 thru Cntrl39.
Thanks
 
I'm not sure of exactly which controls you want to disable, so you
will have to adjust the logical test in the If statement, but this
should give you the idea (paste this code within the click event of a
button or trigger it as you want):

Private Sub CommandButton1_Click()
Dim c As Control
For Each c In Me.Controls
If c.Name = "Cntrl1" Then
c.Enabled = False
End If
Next
End Sub

Good luck,
Randy
 
Back
Top