Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Double click item in Listbox to select item and close Listbox

Have a large complicated VBA Project in which the first item after it starts
is displaying a Listbox with 30 items (single select). Now the user must
select the item and click the OK Button (it works). But from a windows GUI
viewpoint they should be able to just double click the desired item and have
it work the same as select and click OK. I have looked all through the
Properties Window but see nothing to make it work. Just want to make it work
like a real Windows App.
XP Pro - Excel 2003

Any help (even if can't be done) would be appreciated.
--
Gus Evans
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Double click item in Listbox to select item and close Listbox

Have a large complicated VBA Project in which the first item after it
starts
is displaying a Listbox with 30 items (single select). Now the user must
select the item and click the OK Button (it works). But from a windows
GUI
viewpoint they should be able to just double click the desired item and
have
it work the same as select and click OK. I have looked all through the
Properties Window but see nothing to make it work. Just want to make it
work
like a real Windows App.
XP Pro - Excel 2003


Assuming your OK button is an ActiveX control named CommandButton1 for this
example (user your actual control's name, of course), just put this one line
in the ListBox's DoubleClick event...

CommandButton1_Click

and double clicking an item will do the same as selecting an item and
clicking the CommandButton.


Rick

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Double click item in Listbox to select item and close Listbox

Great - worked like a charm!
--
Gus Evans


"Rick Rothstein (MVP - VB)" wrote:

Have a large complicated VBA Project in which the first item after it
starts
is displaying a Listbox with 30 items (single select). Now the user must
select the item and click the OK Button (it works). But from a windows
GUI
viewpoint they should be able to just double click the desired item and
have
it work the same as select and click OK. I have looked all through the
Properties Window but see nothing to make it work. Just want to make it
work
like a real Windows App.
XP Pro - Excel 2003


Assuming your OK button is an ActiveX control named CommandButton1 for this
example (user your actual control's name, of course), just put this one line
in the ListBox's DoubleClick event...

CommandButton1_Click

and double clicking an item will do the same as selecting an item and
clicking the CommandButton.


Rick


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Double click item in Listbox to select item and close Listbox

Hi Gus

You could do it using code like that listed below

Option Explicit
Dim LstSelection As String

Private Sub CommandButton1_Click()
Call DoYourThingHere
End Sub

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Call DoYourThingHere
End Sub

Sub DoYourThingHere()
LstSelection = ListBox1.Value
MsgBox LstSelection
ListBox1.Visible = False
End Sub

hope this helps

S

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ListBox3.ListIndex = ListBox3.ListCount -- How to select the last item in a Listbox? [email protected] Excel Programming 2 March 8th 07 01:14 AM
listbox add item Baha Excel Programming 0 December 8th 06 02:37 AM
Need selected item from listbox after double click [email protected] Excel Programming 1 February 23rd 06 03:18 PM
select listbox item automatically ilyaskazi[_71_] Excel Programming 3 September 14th 05 12:27 PM
Select an item in a listbox using code Fred Jacobowitz Excel Programming 2 August 23rd 04 03:27 AM


All times are GMT +1. The time now is 09:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"