ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Listbox issues (https://www.excelbanter.com/excel-programming/291263-listbox-issues.html)

Mark[_36_]

Listbox issues
 
Hi NG

I have populated a listbox by using listbox1.rowsource
There are many similar entries in the listbox.

The user can then an entry and the listbox_change() callback is called. In
this callback I would like to be able to extract the rownumber of the users
selection e.g. rownumber == 3 if the user chooses row 3 in the listbox. The
reason that I do not use Listbox.value is as i mentioned before the many
similar entries in the listbox.

Regards
Mark





Mark[_36_]

Listbox issues
 
Answering my own question.
Just ad 1,2,...,n in a column i the rowsource and hide the column by setting
the columnwidth property in listbox

Mark

"Mark" wrote in message ...
Hi NG

I have populated a listbox by using listbox1.rowsource
There are many similar entries in the listbox.

The user can then an entry and the listbox_change() callback is called. In
this callback I would like to be able to extract the rownumber of the

users
selection e.g. rownumber == 3 if the user chooses row 3 in the listbox.

The
reason that I do not use Listbox.value is as i mentioned before the many
similar entries in the listbox.

Regards
Mark







Jacob

Listbox issues
 
If you have singleselect use

listbox1.listindex

which returns the row number 0-based.

If you have multiselect you need to loop through the list
and check if the ith row is selected via

listbox1.selected(i)=True

ojv
-----Original Message-----
Hi NG

I have populated a listbox by using listbox1.rowsource
There are many similar entries in the listbox.

The user can then an entry and the listbox_change()

callback is called. In
this callback I would like to be able to extract the

rownumber of the users
selection e.g. rownumber == 3 if the user chooses row 3

in the listbox. The
reason that I do not use Listbox.value is as i mentioned

before the many
similar entries in the listbox.

Regards
Mark




.


Bob Phillips[_6_]

Listbox issues
 
Mark,

Have you looked at the ListIndex property?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark" wrote in message ...
Hi NG

I have populated a listbox by using listbox1.rowsource
There are many similar entries in the listbox.

The user can then an entry and the listbox_change() callback is called. In
this callback I would like to be able to extract the rownumber of the

users
selection e.g. rownumber == 3 if the user chooses row 3 in the listbox.

The
reason that I do not use Listbox.value is as i mentioned before the many
similar entries in the listbox.

Regards
Mark







Mark[_36_]

Listbox issues
 
Thanks thats it!!

"Bob Phillips" wrote in message
...
Mark,

Have you looked at the ListIndex property?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark" wrote in message

...
Hi NG

I have populated a listbox by using listbox1.rowsource
There are many similar entries in the listbox.

The user can then an entry and the listbox_change() callback is called.

In
this callback I would like to be able to extract the rownumber of the

users
selection e.g. rownumber == 3 if the user chooses row 3 in the listbox.

The
reason that I do not use Listbox.value is as i mentioned before the many
similar entries in the listbox.

Regards
Mark










All times are GMT +1. The time now is 07:49 AM.

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