Search in List box

jmazorra

Well-known Member
Joined
Mar 19, 2011
Messages
715
Hello Everyone:

I have a form that consist of a list box and a text field. The list box's properties has a column count of 2 with linked cell C5. The data comes from name range: =eebox!$A$2:$B$25000

The box gives me an employee ID in column 1 and the corresponding employee name in column 2. However, this has about 200 names and therefore I would like to add a search feature for the client to use. I want to search by name. however, when I put in a text field to perform the search I can only link to cell C5 where the ID is and my list box is linked to. Unfortunately, it is unlikely that the client would have this ID, they would want to search by last name.

Is there a way that I can search by employee name in column 2 and as I am typing the last name, can the box begin to show the last names as I put in letters? Do I have to use a text box or can it be done on a combo box? I am open to changing if necessary.

THanks
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
'Here’s a snippet of code to get you started

'Have a form with: TextBox1, ListBox1 (2 cols with data), ListBox1 (1 col)

Private Sub TextBox1_Change()
If Me.TextBox1 = "" Then
Me.ListBox2.Clear
Exit Sub
End If
Me.ListBox2.Clear
For i = 0 To Me.ListBox1.ListCount - 1
If UCase(Left(Me.ListBox1.List(i, 1), Len(Me.TextBox1))) = _
UCase(Me.TextBox1) Then
Me.ListBox2.AddItem Me.ListBox1.List(i, 0) _
& " -- " & Me.ListBox1.List(i, 1)
End If
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,192
Messages
6,170,648
Members
452,344
Latest member
LarryRSch

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