ListBox Multiple Selection

T

Todd Huttenstine

Hey guys

I have a ListBox(ListBox1) that is populated with values.
lets say these matching values can be found in Range
E8:E20. They may or may not be in this range. If a value
that is in the ListBox is matches a value in Range E8:E20,
I need for that value in the ListBox to be selected. How
do I do this?

Thank you
Todd Huttenstine
 
B

Bob Phillips

Hi Todd,

here is some code

Dim i As Long
Dim j As Long

With Me.ListBox1
For i = 0 To .ListCount - 1
On Error Resume Next
j = WorksheetFunction.Match(.List(i), Range("E8:E20"), 0)
If j > 0 Then .Selected(i) = True
j = 0
Next i
End With

--

HTH

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

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