[VBA] MouseMove & "MouseOut" Event

smallxyz

Active Member
Joined
Jul 27, 2015
Messages
393
Office Version
  1. 2021
Platform
  1. Windows
I have a ComboBox ActiveX on Excel.
1. When the mouse hovers over it, the comboBox will drop down.
2. When the mouse leaves the region of ComboBox, the comboBox will collapse.

Task 1 can be done using "MouseMove" event.
However, for task 2, it seems that Excel VBA itself doesn't have corresponding "MouseOut" event to handle it.

Is there any workaround?

Thanks a lot!


Code:
Private Sub ComboBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    ComboBox1.DropDown
End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
What does "collapse" mean?

A simple workaround is to add a LABEL
Make LABEL bigger in ALL directions than the combobox
Givel LABEL a mousemove containing your "collapse" instruction
Move LABEL over the ComboBox overlapping on all sides
Right click on LABEL \ ... Order \ ... Send to back
Use LABEL properties \ ... Back Style \ ... Transparent
Delete LABEL text
You may need to modify LABEL border to make it totally invisible
 
Upvote 0
What does "collapse" mean?

A simple workaround is to add a LABEL
Make LABEL bigger in ALL directions than the combobox
Givel LABEL a mousemove containing your "collapse" instruction
Move LABEL over the ComboBox overlapping on all sides
Right click on LABEL \ ... Order \ ... Send to back
Use LABEL properties \ ... Back Style \ ... Transparent
Delete LABEL text
You may need to modify LABEL border to make it totally invisible
Hi Yongle,
"collapse" means the combobox returns to its original unopen condition.
 
Upvote 0
DropDown is a bit stubborn and does not give up its hold very easily. Selecting an item clears the dropdown

Why mouse_over the ComboBox other than to select an item?
 
Upvote 0
DropDown is a bit stubborn and does not give up its hold very easily. Selecting an item clears the dropdown

Why mouse_over the ComboBox other than to select an item?
I have a worksheet with several comboboxes on top.
Somehow too lazy to click on the desired dropdown button of any particular comboboxes.
Hope to have a VBA script, such that whenever the mouse hovers the combobox, the list will drop down ; whenever mouse leaves it, the list just scrolls up.
 
Upvote 0
I still have not understood the "complete" end goal here
- I understand that you do not want to click on dropdown arrow

What I do not understand is what happens next ....
- the purpose of a dropdown is to allow one or more item to be selected
- selecting any item from the dropdown removes the dropdown instantly
- BUT moving away without selecting any values leaves the dropdown visible (which is your issue)

If all you ever want to do is view a list of items then there are other ways to do that without using a combobox.

Q1 is there ever a requirement to select an item in any of the comboboxes?
Q2 do any of the comboboxes display multiple columns of data?
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top