We help IT Professionals succeed at work.
Get Started

Mouse down event to select item in combo box not working correctly

Last Modified: 2019-12-20
I am using an ActiveX combo box on a worksheet. I am trying to select an item with a mouse. I have found the code below and it does work. However, unless you place the mouse pointer on the very bottom of the item highlighted in blue, it will select the item above it. Is there another way to do this? or is there a way to adjust the code to make this function better?

Private Sub TempCombo_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
   If TempCombo.TopIndex > -1 Then
        Dim curIndex As Integer
        curIndex = TempCombo.TopIndex + Application.WorksheetFunction.RoundDown(y / 13.5, 0)
        CurValue = TempCombo.list(curIndex)
   End If
End Sub

Open in new window

Watch Question
Mississippi Regional Manager
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE