Hi
I have a CB1 combobox, the problem is:
I want to trigger an event ONLY when I click on a value in the drop-down list.
There's a FilterTheComboBox sub that filter as I type in the dropdown list.
For example, suppose a dropdown list with: "House", "House A", "House B".
1) Using MouseClick event, if I type in CB1 a value that exactly matches a value in the list, the MOUSECLICK event will not work when I click the same value in the drop-down list;
Example: In this scenario, if I type "Home", "Home" is highlighted in the drop-down list, if I click "Home", nothing will happen.
i.e. when CB1 value = dropdownlist value absolutely no mouse click event occurs, no matter how much clicks I do in CB1.
2) Using Change event, when I type a value that exactly matches a value in the list, it calls the sub even when I just want to filter the drop-down list.
Example: Type "House" executes the macro with CB1 = "House" but if I do not want it? For example, I want to select "House A" or "House B"?![Frown :( :(](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Any advice?
Thanks
I have a CB1 combobox, the problem is:
I want to trigger an event ONLY when I click on a value in the drop-down list.
There's a FilterTheComboBox sub that filter as I type in the dropdown list.
For example, suppose a dropdown list with: "House", "House A", "House B".
1) Using MouseClick event, if I type in CB1 a value that exactly matches a value in the list, the MOUSECLICK event will not work when I click the same value in the drop-down list;
Example: In this scenario, if I type "Home", "Home" is highlighted in the drop-down list, if I click "Home", nothing will happen.
i.e. when CB1 value = dropdownlist value absolutely no mouse click event occurs, no matter how much clicks I do in CB1.
2) Using Change event, when I type a value that exactly matches a value in the list, it calls the sub even when I just want to filter the drop-down list.
Example: Type "House" executes the macro with CB1 = "House" but if I do not want it? For example, I want to select "House A" or "House B"?
Code:
Private Sub CB1_Change()
Dim z As Integer
If Me.CB1 <> "" Then
For z = 0 To UBound(DropDownList)
If LCase(LCase(Me.CB1)) = LCase(DropDownList(z)) Then Call ModMain.RunMyMacro
Next z
End If
End Sub
Private Sub CB1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Call ModControl.FilterTheComboBox
End Sub
Any advice?
Thanks
Last edited: