VBA in Excel

  • Thread starter Thread starter Dunc_w
  • Start date Start date
D

Dunc_w

I am a new VBA programmer. I have code similiar to:

label1.visible = true
label2.visible = true
label3.visible = true

Clearly this is suitable for a for loop. I an having difficulties figuring
out the code for such an action. Any suggestions?
 
I am a new VBA programmer. I have code similiar to:

label1.visible = true
label2.visible = true
label3.visible = true

Clearly this is suitable for a for loop. I an having difficulties figuring
out the code for such an action. Any suggestions?

Hello Dunc_w,

Provided these labels are on a UserForm and the numbers are sequential
then this will work...
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sub ShowLabels()

Dim I

For I = 1 To 3
UserForm1.Controls("Label" & I).Visible = True
Next I

End Sub
 
Hello Leith,

I tried a similar one but this one do not work. The code is executing
without an error but the captions are not changed.

L_HP_1 is a Label Name
and Camp_CF is a userform

Sub ShowLabels()

Dim I As Integer

For I = 1 To 3
Camp_CF.Controls("L_HP_" & I).Caption = "Akash"
Next I

End Sub
 

Ask a Question

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.

Ask a Question

Back
Top