I want to be able to do something to several labels, e.g. make them invisible, using a FOR loop. They are all named similarly, with ascending numbers on the end, e.g. lblName20
Say I want to make lblName20 to lblName40 invisible. I need something along the lines of:
Of course, that doesn't work, because it doesn't recognize the string as a label name. I'm sure there must be something simple I'm overlooking - unfortunately, my VBA is very rusty!
How do I go about this?
Say I want to make lblName20 to lblName40 invisible. I need something along the lines of:
Code:
Dim labelname As String
For c = 20 To 40
labelname = "lblName" & c
labelname.Visible = False
Next c
Of course, that doesn't work, because it doesn't recognize the string as a label name. I'm sure there must be something simple I'm overlooking - unfortunately, my VBA is very rusty!
How do I go about this?