Option
Explicit
Private
col
As
Collection
Private
WithEvents
myCombobox
As
MSForms.ComboBox
Private
Sub
UserForm_Initialize()
Set
col =
New
Collection
Set
myCombobox =
Me
.Controls.Add(
"Forms.ComboBox.1"
,
"cmbTest"
,
True
)
With
myCombobox
.AddItem
"Test"
.AddItem
"Test2"
End
With
col.Add myCombobox
End
Sub
Private
Sub
myCombobox_Change()
If
Me
.Controls(
"cmbTest"
).Value = vbNullString
Then
Set
myCombobox =
Me
.Controls.Add(
"Forms.ComboBox.1"
,
"cmbTest2"
,
True
)
Me
.Controls(
"cmbTest2"
).Move 0, 25
col.Add myCombobox
End
If
End
Sub