ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserForm with ListBox (https://www.excelbanter.com/excel-programming/318350-userform-listbox.html)

Otto Moehrbach[_6_]

UserForm with ListBox
 
Excel 2002, WinXP
I have a UserForm with a ListBox and OK and Cancel buttons.
I know how to deal with a selection in the ListBox when the user makes a
selection and clicks the OK button.
But sometime in the past I was able to induce code action with just the
selection of an item (multi-select set to 1) in the ListBox. IOW, there was
no OK button or a need for an OK button.
How do I do that?
Thanks for your help. Otto



Jim Cone

UserForm with ListBox
 
Hi Otto,

You are looking for the "ListBox1_Click()" event
or
the "ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)" event.
They are found in the form module.

Regards,
Jim Cone
San Francisco, CA


"Otto Moehrbach" wrote in message ...
Excel 2002, WinXP
I have a UserForm with a ListBox and OK and Cancel buttons.
I know how to deal with a selection in the ListBox when the user makes a
selection and clicks the OK button.
But sometime in the past I was able to induce code action with just the
selection of an item (multi-select set to 1) in the ListBox. IOW, there was
no OK button or a need for an OK button.
How do I do that?
Thanks for your help. Otto



Chip Pearson

UserForm with ListBox
 
Otto,

You can use the Click event of the Listbox control to execute
code with the user selects an item in the list. E.g.,

Private Sub ListBox1_Click()
' your code here
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I have a UserForm with a ListBox and OK and Cancel buttons.
I know how to deal with a selection in the ListBox when the
user makes a selection and clicks the OK button.
But sometime in the past I was able to induce code action with
just the selection of an item (multi-select set to 1) in the
ListBox. IOW, there was no OK button or a need for an OK
button.
How do I do that?
Thanks for your help. Otto




Otto Moehrbach[_6_]

UserForm with ListBox
 
Jim, Chip
Thanks for that. I'll try it out. Otto
"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I have a UserForm with a ListBox and OK and Cancel buttons.
I know how to deal with a selection in the ListBox when the user makes a
selection and clicks the OK button.
But sometime in the past I was able to induce code action with just the
selection of an item (multi-select set to 1) in the ListBox. IOW, there
was no OK button or a need for an OK button.
How do I do that?
Thanks for your help. Otto




Chip Pearson

UserForm with ListBox
 
Otto,

Jim's reply was better than mine. To replicate a button press,
you should use the DoubleClick event not the Click event.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Otto Moehrbach" wrote in message
...
Jim, Chip
Thanks for that. I'll try it out. Otto
"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I have a UserForm with a ListBox and OK and Cancel buttons.
I know how to deal with a selection in the ListBox when the
user makes a selection and clicks the OK button.
But sometime in the past I was able to induce code action with
just the selection of an item (multi-select set to 1) in the
ListBox. IOW, there was no OK button or a need for an OK
button.
How do I do that?
Thanks for your help. Otto







All times are GMT +1. The time now is 01:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com