I have a userform with 5 comboboxes that I want to add to a class module so that my code runs whenever a box value is changed. I have this so far:
On Userform Initialize:
In Class Module ("Class_Comboboxes")
When the userform first initializes, I get a message box "Changed" for each one as they get populated. But after that, the message box does not appear when I change one of their values. I must be missing something?
On Userform Initialize:
Code:
'Assign all Comboboxes to ComboBoxes class module so that if any Combobox is clicked, _
Class module code will run
Dim ComboBoxControl As Control
Dim ComboBoxClass As Class_ComboBoxes
Set ComboBoxCollection = New Collection
For Each ComboBoxControl In Me.Controls
If TypeName(ComboBoxControl) = "ComboBox" Then
Set ComboBoxClass = New Class_ComboBoxes
Set ComboBoxClass.ComboBox = ComboBoxControl
ComboBoxCollection.Add ComboBoxClass
End If
Next ComboBoxControl
In Class Module ("Class_Comboboxes")
Code:
Public WithEvents ComboBox As MSForms.ComboBox
Private Sub ComboBox_Change()
MsgBox "changed"
End Sub
When the userform first initializes, I get a message box "Changed" for each one as they get populated. But after that, the message box does not appear when I change one of their values. I must be missing something?