I have a userform(GLSplit) that has 25 combo boxes names ComboBox1.. ComboBox2 etc. inserted on the user form at design and sitting on a Frame.
Problem: I want to use the the same click or enter event to populate these controls when the control gets focus. I used the suggested code found at
http://www.ozgrid.com/forum/showthread.php?t=172689&highlight=event+multiple+comboboxes
but the event will not fire.
Code in class module named:GLSplitCB set to Private
Code
Option Explicit
Public WithEvents myCBox As MSForms.ComboBox
Private Sub myCBox_Enter()
MsgBox "Fired"
BuildGLPickList 'Public Procedure to build list of items for dropdown in combobox (called from main module)
End Sub
Code inserted into Userform module
Code
Dim myCommonComboBoxes As New Collection 'Inserted at top of module
Private Sub UserForm_Initialize()[INDENT]Dim oneBox As GLSplitCB
'.... my code
For item = 1 To 25 'Set all comboboxes to use same click event
Set oneBox = New GLSplitCB
Set oneBox.myCBox = Me.Controls("ComboBox" & Format(item)) 'I changed "cbo" to "ComboBox" Tired both ways. Neither works.
myCommonComboBoxes.Add item:=oneBox
Next item
Set oneBox = Nothing
'.... my code
end sub
Display More