E
ExcelMonkey
Wy am I getting Run time error 91 when trying to add controls to my collection.
Public cntrlclctn1 As Collection
Sub thing()
Dim lbl As Control
Dim txtbx As Control
'Create controls
Set lbl = UserForm1.Controls.Add("Forms.Label.1")
lbl.Caption = "Label Text"
Set txtbx = UserForm1.Controls.Add("Forms.TextBox.1")
txtbx.Text = "Text Box Text"
'Add controls to collection
cntrlclctn1.Add (lbl)
cntrlclctn1.Add (txtbx)
UserForm1.Show
End Sub
Public cntrlclctn1 As Collection
Sub thing()
Dim lbl As Control
Dim txtbx As Control
'Create controls
Set lbl = UserForm1.Controls.Add("Forms.Label.1")
lbl.Caption = "Label Text"
Set txtbx = UserForm1.Controls.Add("Forms.TextBox.1")
txtbx.Text = "Text Box Text"
'Add controls to collection
cntrlclctn1.Add (lbl)
cntrlclctn1.Add (txtbx)
UserForm1.Show
End Sub