0

I'm trying to call a change event for any Combo Box on a userform.

UPDATE

So following what others have said (For Text Boxes, which I've tested and works for Textboxes), I've create a Class Module Called: 'clsCombo_Update'

Private WithEvents MyComboBox As MSForms.comboBox

Public Property Set Control(cb As MSForms.comboBox)
    Set MyComboBox = cb
End Property

Private Sub MyComboBox_Change()
    Debug.Print "Change"
End Sub

And in the UserForm I have:

Private Sub UserForm_Initialize()

    Dim ctrl As MSForms.Control
    Dim obj As clsCombo_Update

    Set cbCollection = New Collection
        For Each ctrl In Me.Controls
            If TypeOf ctrl Is MSForms.comboBox Then
                Set obj = New clsCombo_Update
                Set obj.Control = ctrl
                cbCollection.Add obj
            End If
        Next ctrl
    Set obj = Nothing

End Sub

This setup worked for textboxes but doesn't when I tried to make it work for Combo Boxes

  • Can you simply have a "submit" button on the combo box, or something similar? – Selkie Sep 05 '18 at 15:59
  • 1
    Have a look here: https://stackoverflow.com/questions/1083603/vba-using-withevents-on-userforms – Sam Sep 05 '18 at 16:06

0 Answers0