I've been searching on the internet trying to find what the meaning of listcount -1
is, but i can't seem to find the exact answer.
why is there -1
beside the listcount? or .list(.listcount -1,1)
what is that mean?
edit
example of the listcount
.additem a.value
.list(.listcount -1, 1) = ws.cells(A,B).value
this adds the value of ws.cells(A,B)
to the listbox1 but i don't understand why/how?
or i found a code
on the internet http://www.ozgrid.com/VBA/multi-select-listbox.htm
i understand that the purpose of the code is "if one of the list is selected, then transfer the value of listbox into cells" but why is there .Listbox1.Listcount -1
?
To make things clearer, as I've said,
ListCount
starts at1
when countingListBox
items orList
.But
ListBox Indexing
of those items orList
starts at0
. In your example, you are trying to add an item orList
in aMulti-Column ListBox
.Take a look at below example:
Above code populates a
ListBox
initially set with 3 columns.This line
.Add "Item"
adds the firstList
in theListBox
.But you need to populate the rest of the columns.
To access those columns, you use
.List
property with this syntax:pvargIndex
is theListBox ListIndex
andpvargColumns
is the column number.Remember that you already added 1
item
using the.Add
property and theListIndex
of that item is?To learn more about pupulating
ListBox
, check THIS out.Also see HERE.
Hope above helps you somehow.