Mouse double-click to select listbox item and run userform

L

Lemi

Excel 2007 and XP Pro:
I have a UserForm with several list boxes. Normally I select items from
relevant listboxes and press OK button to continue with the macro.
Can I do the same by just double-clicking on any item of any listbox in the
Form, that is, combining list item selection and pressing OK into one
double-click?

Regards,
Lemi
 
R

RB Smissaert

There is no double-click event, but you could measure the time between 2
click events
or mouse-down events and make your own double-click.
How about triggering the action with a right mouse-down?

RBS
 
L

Lemi

Hi RBS,

Thank you. However I have just found out that there was double-click event.
See below:

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

UserForm1.Hide 'put here exactly whatever your OK button does

End Sub

It works..
Lemi
 
R

RB Smissaert

Ah, yes it has! Nice and simple then.

RBS


Lemi said:
Hi RBS,

Thank you. However I have just found out that there was double-click
event. See below:

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

UserForm1.Hide 'put here exactly whatever your OK button does

End Sub

It works..
Lemi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top