Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Listbox Initial Values

I have two listbox controls named FROM and TO
The rowsource for both is the same, but variable in length. When the user
form loads, I would like to have FROM display and select the first value in
the rowsource, and to have TO display and select the last value in the
rowsource. Using TOPINDEX causes the correct value to be displayed, but the
returned value is null.

Any suggestions please?

Thanks.

Marvin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Listbox Initial Values

If you have only one column in the ListBox and the BoundColumn is set to 1,
then you can use the Value property to return the displayed value.

x = UserForm1.ListBox1.Value
MsgBox x

Would display the selected value. Also see the Selected property in VBA help.

"Marvin Buzz" wrote:

I have two listbox controls named FROM and TO
The rowsource for both is the same, but variable in length. When the user
form loads, I would like to have FROM display and select the first value in
the rowsource, and to have TO display and select the last value in the
rowsource. Using TOPINDEX causes the correct value to be displayed, but the
returned value is null.

Any suggestions please?

Thanks.

Marvin

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Listbox Initial Values

To return the last item in the list box.

y = UserForm1.ListBox1.Selected(ListBox1.Rows.Count -1)
MsgBox y

ListBox row index begins with zero, so the last item index number will be
one less that the number of rows.


"Marvin Buzz" wrote:

I have two listbox controls named FROM and TO
The rowsource for both is the same, but variable in length. When the user
form loads, I would like to have FROM display and select the first value in
the rowsource, and to have TO display and select the last value in the
rowsource. Using TOPINDEX causes the correct value to be displayed, but the
returned value is null.

Any suggestions please?

Thanks.

Marvin

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Listbox Initial Values

Maybe my requirement wasn't clear. I want the FROM box to display the first
item from rowsource, and the TO box to display the last. Additionally, the
values to be returned from the controls must be the first and last
respectively.

Marvin

"JLGWhiz" wrote:

To return the last item in the list box.

y = UserForm1.ListBox1.Selected(ListBox1.Rows.Count -1)
MsgBox y

ListBox row index begins with zero, so the last item index number will be
one less that the number of rows.


"Marvin Buzz" wrote:

I have two listbox controls named FROM and TO
The rowsource for both is the same, but variable in length. When the user
form loads, I would like to have FROM display and select the first value in
the rowsource, and to have TO display and select the last value in the
rowsource. Using TOPINDEX causes the correct value to be displayed, but the
returned value is null.

Any suggestions please?

Thanks.

Marvin

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
Combo Box initial values question teepee Excel Discussion (Misc queries) 8 May 13th 07 12:57 AM
Combo Box initial values question teepee Excel Programming 8 May 13th 07 12:57 AM
What gets XNPV to calculate correctly if initial values are zero? Jim McCartney Excel Worksheet Functions 1 July 21st 06 04:37 AM
Fill values into a listbox matching selected values from a combobox Jon[_19_] Excel Programming 4 January 25th 05 04:25 PM
Sorting ListBox results or transposing ListBox values to other cells for sorting Rob[_8_] Excel Programming 1 July 9th 03 04:35 AM


All times are GMT +1. The time now is 03:01 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"