Select row in list box programatically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Thanks for taking the time to read my question.

I would like to select an item in my listbox with code.

so far I have:
Me.CategoryList.Column(1, x) but you can't add anything after that.

It also is incorrect. If I add Msgbox before it, it returns that value.

I'd like to select that value.

How do I do that?

I don't think ListIndex, ItemData are the right ones either.

Thanks again,

Brad
 
Hi,
It's hard to tell how you want to use this but, here's one way:

Dim i As Integer
For i = 0 To Me.CategoryList.ListCount - 1
If Me.CategoryList.Column(0, i) = Me.CategoryList.Column(1, x) Then
Me.List0.Selected(i) = True
End If
Next i
 
Hi,
Sorry, wrong list box in previous code :-)
Dim i As Integer
For i = 0 To Me.CategoryList.ListCount - 1
If Me.CategoryList.Column(0, i) = Me.CategoryList.Column(1, x) Then
Me.CategoryList.Selected(i) = True
End If
Next i
 
Back
Top