Apurv Pawar
Apurv Pawar

Reputation: 424

Userform1.Label1 Need to have a loop to update 20 Labels.Caption

I have a macro where I need to update 20 labels using a loop to update range a1 to a20 as Label captions, but I am getting error. I am getting error because I am using Label&j. Please suggest an alternative

Sub NameListAllocate()
k = Range("Q65536").End(xlUp).Row

For j = 2 To k
UserForm1.Label&j.Caption = Range("q" & j).Value
Next

UserForm1.Show
End Sub

Upvotes: 0

Views: 777

Answers (1)

Kostas K.
Kostas K.

Reputation: 8518

UserForm1.Controls("Label" & j).Caption = Range("q" & j).Value

Upvotes: 1

Related Questions