Initiate command when userform's combo box is clicked

MistakesWereMade

Board Regular
Joined
May 22, 2019
Messages
103
Is there a way to initiate commands when a combobox is activated? In other words, if the cursor does not appear in a combobox, but then the combobox is clicked and the cursor populates the combobox, can I have commands run? I am not looking for ComboBox_Change, I am more looking for something like if the combobox goes from unselected to selected or inactive to activated...
 

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
Is there a way to initiate commands when a combobox is activated? In other words, if the cursor does not appear in a combobox, but then the combobox is clicked and the cursor populates the combobox, can I have commands run? I am not looking for ComboBox_Change, I am more looking for something like if the combobox goes from unselected to selected or inactive to activated...


Not exactly. In the past, I have just resorted to using labels for this sort of thing.



Create your combo box. Now create a label, size it to perfectly cover your combobox. (I normally do not cover the pulldown button as i prefer to add code to the downarrow click event)
Set the BackStyle on the label to be transparent.


When people THINK they are clicking your combobox, they are actually clicking a label(Invisible to them)

Labels have built in "on click" handles that you can code.

Just be sure to add a line of code to your label click event as such..


ComboxBox1.SetFocus



So, the user clicks the combobox(which had an invisible label over it), the label click event fires your code, and then the label sets the focus to the combobox the user tried to click in the first place.


Enjoy.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

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