ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ListBox Multiple Selection (https://www.excelbanter.com/excel-programming/296326-listbox-multiple-selection.html)

Todd huttenstine

ListBox Multiple Selection
 
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

Bob Phillips[_6_]

ListBox Multiple Selection
 
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)

"Todd Huttenstine" wrote in message
...
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





All times are GMT +1. The time now is 08:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com