I have a userform with a sample combobox list like this:
Each CooBox1-10 comobox created has two items Test1 and Test2. I would like the procedure to be launched after clicking on any CooBox and changing from Test1 to Test2. The following example doesn't work. What am I doing wrong?
VBA Code:
Private Sub UserForm_Initialize()
Dim CooBox As MSForms.ComboBox, CooBoxPoz As String
Dim x As Integer
For x = 1 To 10
CooBoxPoz = "CooBox" & x
Set CooBox = UserForm1.Controls.Add("Forms.Combobox.1", CooBoxPoz, True)
Call DynamicForms(CooBox, 90, 34 + ((x - 1) * 20), 126)
UserForm1.Controls(CooBoxPoz).AddItem "Test1"
UserForm1.Controls(CooBoxPoz).AddItem "Test2"
Next
End Sub
Sub DynamicForms(ByRef Element As MSForms.Control, ElLeft As Long, _
ElTop As Long, ElWidth As Long, Optional ElCaption As String)
'On Error Resume Next
If ElCaption <> "" Then
Element.Caption = ElCaption
End If
Element.Left = ElLeft
Element.Top = ElTop
Element.Width = ElWidth
End Sub
Each CooBox1-10 comobox created has two items Test1 and Test2. I would like the procedure to be launched after clicking on any CooBox and changing from Test1 to Test2. The following example doesn't work. What am I doing wrong?
VBA Code:
Private Sub CooBox3_Click()
MsgBox "3 click"
End Sub
Private Sub CooBox3_Change()
MsgBox "3 change"
End Sub