How do I change the state of an item in a (form) multiselect list box

  • Thread starter professorplum101
  • Start date
P

professorplum101

I have a multiselect list box in a form that I need to use to
manipulate some other data. I have already defeated the problem of
getting useful data out of the list box. The problem is that when the
form with the list box is loaded, it populates the list box from
scratch. How can I make the code select a specific entry?
Listname.List(i).Select does not work.

I can properly identify every list item that is being added and know
its position in the list (as well as a reference cell that indicates
if it should be selected). I just can't figure out how to select the
appropriate items.

Help would be greatly appreciated! Thanks!

Brian
 
N

Norman Jones

Hi Brian,

Try usuing the ListBox's ListIndex property, the first item
is item 0, the second is item 1.

For example, to select the fourth item, try something like:

'=============>>
Private Sub UserForm_Initialize()
With Me.ListBox1
.ColumnCount = 4
.List = Range("A1:D20").Value
.ListIndex = 3
End With
End Sub
'<<=============
 
G

Guest

I'm not sure what you are after but:

ListBox1.Value = ListBox1.ListIndex(YourIndexNumber)

This should return the value of whichever index number you put in the
parentheses.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top