Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Listbox - First item in list "default"

I use a userform with a listbox. More than 50% of the time the first
option from the list will be selected by the user. I'm pretty sure I've seen
it somewhere that the first entry can be the "default" selection in which
case the user just hit enter for the selection, however I can't find it.
Any idea how this can be achieved ?

Example of userform [xl2003]
Sub KryKlaRek()
Uklarek.ListBox1.Clear
reDoCli:
Uklarek.ListBox1.RowSource = "ListClient"
Uklarek.Show
If Not bContinue Then End
With Uklarek.ListBox1
If .ListIndex = -1 Then
MsgBox "You did not select a client"
GoTo reDoCli
Exit Sub
End If
If Range("BronInlig!KlaKies").Value = 1 Then Range("broninlig!tydrek").Value
= Uklarek.ListBox1.Value
Range("broninlig!tydkla").Value = Uklarek.ListBox1.Value
End With
Unload Uklarek
Exit Sub
End Sub

--
HJN
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 320
Default Listbox - First item in list "default"

Make the .Listindex = 0

"Hennie Neuhoff" wrote in message
...
I use a userform with a listbox. More than 50% of the time the first
option from the list will be selected by the user. I'm pretty sure I've
seen
it somewhere that the first entry can be the "default" selection in which
case the user just hit enter for the selection, however I can't find it.
Any idea how this can be achieved ?

Example of userform [xl2003]
Sub KryKlaRek()
Uklarek.ListBox1.Clear
reDoCli:
Uklarek.ListBox1.RowSource = "ListClient"
Uklarek.Show
If Not bContinue Then End
With Uklarek.ListBox1
If .ListIndex = -1 Then
MsgBox "You did not select a client"
GoTo reDoCli
Exit Sub
End If
If Range("BronInlig!KlaKies").Value = 1 Then
Range("broninlig!tydrek").Value
= Uklarek.ListBox1.Value
Range("broninlig!tydkla").Value = Uklarek.ListBox1.Value
End With
Unload Uklarek
Exit Sub
End Sub

--
HJN



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
Data Validation - List - with "Add Item..." Neon520 Excel Discussion (Misc queries) 0 March 9th 09 04:44 PM
Listbox header inside VBA (Array("Head1", "Head2", ...) Alex St-Pierre Excel Programming 2 October 25th 06 09:28 PM
Make typing "jump" to matching item(s) in drop-down list? Kathy Excel Discussion (Misc queries) 4 November 22nd 05 10:25 PM
Listbox "expand range as list grows" TK Excel Programming 3 September 8th 04 11:57 PM
ListBox "picking the same item repeatedly" TK Excel Programming 3 August 29th 04 08:13 PM


All times are GMT +1. The time now is 02:12 AM.

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

About Us

"It's about Microsoft Excel"