ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combobox Item Number (https://www.excelbanter.com/excel-programming/295822-combobox-item-number.html)

Todd huttenstine

Combobox Item Number
 
Lets say there are 20 items that can possible be chosen
out of a combobox. Lets say I selected the
value "April". The value April is the 4th item in the
combobox. What is the code that will return 4? I just
need a code that will return the location number of the
value that I selected.


Thank you
Todd Huttenstine

Vasant Nanavati

Combobox Item Number
 
ComboBox1.ListIndex + 1

(The index is zero-based, so the first item has a ListIndex of 0).

--

Vasant




"Todd Huttenstine" wrote in message
...
Lets say there are 20 items that can possible be chosen
out of a combobox. Lets say I selected the
value "April". The value April is the 4th item in the
combobox. What is the code that will return 4? I just
need a code that will return the location number of the
value that I selected.


Thank you
Todd Huttenstine




Harald Staff

Combobox Item Number
 
Hi Todd

Combo1.ListIndex + 1

(since item 1 is listindex 0 )

HTH. Best wishes Harald

"Todd Huttenstine" skrev i melding
...
Lets say there are 20 items that can possible be chosen
out of a combobox. Lets say I selected the
value "April". The value April is the 4th item in the
combobox. What is the code that will return 4? I just
need a code that will return the location number of the
value that I selected.


Thank you
Todd Huttenstine




Vasant Nanavati

Combobox Item Number
 
Hah ... beat you to it!

I must be feeling better ... :)

Regards,

Vasant.

"Harald Staff" wrote in message
...
Hi Todd

Combo1.ListIndex + 1

(since item 1 is listindex 0 )

HTH. Best wishes Harald

"Todd Huttenstine" skrev i melding
...
Lets say there are 20 items that can possible be chosen
out of a combobox. Lets say I selected the
value "April". The value April is the 4th item in the
combobox. What is the code that will return 4? I just
need a code that will return the location number of the
value that I selected.


Thank you
Todd Huttenstine






kkknie[_57_]

Combobox Item Number
 
If you mean VB, you can use the listindex

i = Combo1.Listindex

One thing to note is that the listindex property is zero based, so i
you are looking for the fourth item in the list, it will have
listindex of 3.

Also, to get the value for an item where you know the listindex, yo
would use:

strValue = Combo1.List(1)

Which would retrieve the second value in your list.

K

Edit: Way too slow I see..

--
Message posted from http://www.ExcelForum.com


Harald Staff

Combobox Item Number
 
"Vasant Nanavati" <vasantn *AT* aol *DOT* com skrev i melding
...

Hah ... beat you to it!

Bah. Fix your system clock! <bg

I must be feeling better ... :)

Glad to hear that Vasant.

Best wishes Harald




All times are GMT +1. The time now is 05:34 PM.

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