I am trying to write a code for a search button which searches a listbox based a specific input set in a textbox. The values searched are always numbers, and the listbox contains values from a single column. The code i wrote can be found below but i don't understand why it is not functional.
Legend:
Thanks for your help :)
Private Sub SearchButton_Click()
Dim SearchCriteria, i, n As Double
SearchCriteria = Me.SearchBox.Value
n = AvailableNumberList.ListCount
For i = 0 To n - 1
If SearchCriteria = i Then
AvailableNumberList.ListIndex = i
End If
Next i
End Sub
Is this what you are trying?
'If SearchCriteria = i Then
If AvailableNumberList.List(i) = SearchCriteria Then
Also use Exit For
once a match is found :)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments