Hi Leungkong,
There is no "label" collection.
I assume that your labels are on a userform.
You need to loop throught the Controls collection of your Userform and
by using the .Item property. This uses base 0. So to loop through 10
labels your loop should be from 0 to 9. Then test each control to see
if it is a label. If it is then do whatever you want.
You could also user the Userform.Controls.Count property so you dont
have to change your loop if you add more labels.
Hope this is what you were looking for.
Kind regards
Bernie Russell
-------------------------------------------------------------------
Private Sub UpdateLabels()
On Error GoTo Err_UpdateLabels
Dim i As Integer
With UserForm1.Controls
For i = 0 To 9 'Alternatively Userform.Controls.Count -1
If (TypeOf .Item(i) Is MSForms.Label) = True Then .Item(i).Visible =
False
'If (TypeOf .Item(i) Is MSForms.Label) = True Then .Item(i).Visible
= True
Next i
End With
Err_UpdateLabels:
Debug.Print Err.Description
End Sub
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.