Search listbox index from two inputs ofTextbox

Asked

Viewed 14 times

0

Good afternoon,

The goal is to find the index in the Listbox corresponding to two textbox values. Textbox1 looks for the value in column 0 and textbox2 in column 1. Both of these values in listbox are numbers.

At this point I have the following code which only finds the corresponding value in column 0:

Private Sub CommandButton4_Click()
Dim i As Long
Dim n As Long
Dim Str As String

Str = Me.TextBox1.Text
n = Me.ListBox1.ListCount
For i = 0 To n - 1
If Right(Me.ListBox1.List(i), Len(Str)) = Str Then
Me.ListBox1.ListIndex = i
Exit Sub
End If
Next i
End Sub

Column 0 may have more than one index with the same value, but never the set of values in column 0 and 1.

Thank you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.