2017-06-02 27 views
0

我有一個宏,我需要更新20個標籤使用循環更新範圍a1到a20作爲標籤標題,但我收到錯誤。 我收到錯誤,因爲我正在使用標籤& j。請建議替代Userform1.Label1需要有一個循環來更新20 Labels.Caption

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 

回答

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

感謝科斯塔斯,它的工作原理.. –