ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Listbox (https://www.excelbanter.com/excel-programming/279104-listbox.html)

Stephen[_5_]

Listbox
 
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?



merjet

Listbox
 
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



Tim Zych[_4_]

Listbox
 
To add, maybe you can adapt some ideas from my page:

http://www.rubbershoe.com/listboxlookup.htm


"Stephen" wrote in message
...
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?








All times are GMT +1. The time now is 12:01 AM.

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