Listbox

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

I have changed my list box MatchEntry to fmMatchEntryComplete so that I can
type in complete words to find a match in my list.

What I would like to do is to replicate this search ability but have the
listbox displaying matched entries from a textbox using the textbox change
event to initialize the search.

So instead of typing the search string in the list box I would type it in
the textbox but have the listbox responding as though I had typed the string
in the listbox.

Can this be done?
 
Your post wasn't real clear to me since a ListBox is
not for typing in entries. But suppose all the ListBox
candidates are in Sheets("Sheet1").Range("A1:A20").

Then the following code should work.

Private Sub TextBox1_Change()
ListBox1.Clear
For Each c In Sheets("Sheet1").Range("A1:A20")
If TextBox1.Text = Left(c, Len(TextBox1.Value)) Then
ListBox1.AddItem c
End If
Next c
End Sub

HTH,
Merjet
 
Back
Top