Hello,
i have a listbox containg about 150 items. when i use vba to count the
number of items, both UBound and ListCount tell me there are 128 items.
How come it doesnt say there are 150 items??
Thanks for any help...
JasperWhat is the source data for the listbox?
If it is a range could a simple Excel function such as COUNTA() or ROWS()
work?
or is the listbox populated some other way.
I've never used the VBA you mentioned, sorry to say. But looking them up in
quot;helpquot; it doesn't look like they determine the cardinality of set of items
populating list box. UBOUND determines a max value within an array diminsion
and ListCount determines count of rows over which you can scroll.
Maybe a more experienced programmer can elucidate for us.
Regards
E.Q. C.
quot;Jasperquot; wrote:
gt; Hello,
gt;
gt; i have a listbox containg about 150 items. when i use vba to count the
gt; number of items, both UBound and ListCount tell me there are 128 items.
gt; How come it doesnt say there are 150 items??
gt;
gt; Thanks for any help...
gt; Jasper
gt;
gt;
I used another macro that put the names of 146 different sheets (in the
same workbook) in the listbox. i put them in a listbox so i can double
click on the name so i jump to the corresponding sheet (i know i can
use the arrows next to the name of the most left sheet to do this, but
i want to use a listbox).
i need to last item in the listbox so i can use a loop to sort them. if
i dont use the last item number (128 in this case) but make enter (for
example) 150 as the end of the loop, then by the time the loop reaches
item 129 i get an error stating there is no item 129 (while obviously
there is...).
i hope that clarifies?Would it be possible to hack into your original macro and insert an index
that could be used in your sorting macro? (Does it use a quot;for eachquot;
construction?) Or perhaps your list-populating macro could also perform a
sort?
I apologize for not being able to answer directly, but perhaps you can find
a work-around.
quot;Jasperquot; wrote:
gt; I used another macro that put the names of 146 different sheets (in the
gt; same workbook) in the listbox. i put them in a listbox so i can double
gt; click on the name so i jump to the corresponding sheet (i know i can
gt; use the arrows next to the name of the most left sheet to do this, but
gt; i want to use a listbox).
gt;
gt; i need to last item in the listbox so i can use a loop to sort them. if
gt; i dont use the last item number (128 in this case) but make enter (for
gt; example) 150 as the end of the loop, then by the time the loop reaches
gt; item 129 i get an error stating there is no item 129 (while obviously
gt; there is...).
gt;
gt; i hope that clarifies?
gt;
gt;
- Sep 29 Fri 2006 20:09
Determine size of listbox
close
全站熱搜
留言列表
發表留言