Search as you Type using TextBox and List Box

simeonemj

New Member
Joined
Mar 26, 2009
Messages
1
Hi:

I have created a list box in Excel VBA using the following code:

****************************

Private Sub UserForm_Initialize()

Dim RC, RC2 As Integer

'Selects the "Draft Sheet" worksheet
Sheet1.Select
Range("D2").Select

RC = 2
Set menusheet = ThisWorkbook.Sheets("Draft Sheet")

With ListBox1
Do Until IsEmpty(menusheet.Cells(RC, 4))
If menusheet.Cells(RC, 10) = "" Then
.AddItem menusheet.Cells(RC, 4)
End If
RC = RC + 1
Loop
End With

End Sub

****************************

What I'd like to do now is use the TextBox1 to be able to type a name and have it search the ListBox1 while simultaneously removing all the other ListBox1 items that do not match what I am typing. I have seen some similar posts on this topic but could not quite understand them.

Thanks,

Matt
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,214,649
Messages
6,120,731
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top