PDA

View Full Version : How to Populate Userform Labels from a Range



uaku
04-26-2011, 11:08 AM
Hi,
I am trying to populate userfrom Labels from worksheet range. I have more than 25 labels so I want to write a macro, I tried below code but it did not work

Private Sub UserForm_Activate()
Dim Val As Range
No = 1
For Each Val In Range("A6:C6")
Labels = "Lable" & No
MsgBox Labels
Labels.Caption = Val
No = No + 1
Next
End Sub
Thanks for your help
Aku:think:

mikerickson
04-26-2011, 12:46 PM
This is one way to loop through userform labels.Dim i As Long

For i = 1 to 10
UserForm1.Controls("Label" & i).Caption = Range("A1:A10").Cells(i, 1).Value