I am trying to search a word in a textbox, it shows in a listbox what I am looking for, the texbox1 code works well, the issue is the second code "selec", when I select the correct one, it does not do anything. I would like to select the word in the listbox, press enter and have it populatedin the textbox as when you are looking something from google,
If I erase somehting in the textbox, and write another word, press enter in the listbox, then the texbox should be populated
thank you
If I erase somehting in the textbox, and write another word, press enter in the listbox, then the texbox should be populated
thank you
Code:
Private Sub TextBox1_Change()
Dim rng As Range, e
Set Lista = Range("lstProductos")
With Me
.ListBox1.Clear
For Each i In Lista.Value
If (i <> "") * (i Like "*" & .TextBox1.Value & "*") Then
.ListBox1.AddItem i
End If
Next i
End With
End Sub
Private Sub selec()
Cuenta = Me.ListBox1.ListCount
For i = 0 To Cuenta - 1
If Me.ListBox1.Selected(i) = True Then
texbox1.Value = Me.ListBox1.List(i) ' does not work
End If
Next i
End Sub