Event handlers do one thing: they handle events. That's why they're Private
: they never need to be explicitly invoked by any other code - they're invoked by their respective event source, period.
If it's bad practice in every language I could be bothered to find a SO post about this for, then why would it be any different in VBA? Hint: it's not, the reasons why explicitly invoking an event handler is a bad idea, are completely language-agnostic (provided your language has a concept of "event").
Don't make them Public
and then invoke them explicitly. Instead, have that other code toggle the state of the control, and let the control fire its event - assuming an ActiveX/MSForms control:
Dim ctrl As MSForms.ComboBox
Set ctrl = wb.Worksheets("Sheet2").OLEObjects("ComboBox1").Object
ctrl.Value = Not ctrl.Value
If you don't want to toggle the control's state, only to invoke its handler, then pull the handler's implementation out - instead of this:
Private Sub ComboBox_Change()
'do stuff
End Sub
Do this:
Private Sub ComboBox_Change()
DoStuff
End Sub
Public Sub DoStuff()
'do stuff
End Sub
And then invoke DoStuff
like you would any other macro-in-another-workbook.
Note that the Call
keyword is completely redundant.