VBA Partial Search

GedSalter

Board Regular
Joined
Apr 24, 2019
Messages
80
Hi All,

I have the following code. The search works well but I would like it to work as a partial search then if several matches display a list box with each match which I can then select. I have no clue how to do this. I have looked around and not seen anything particular that I could use. This is all incorporated within a userform.


VBA Code:
Private Sub CommandButton2_Click()

Dim Firstname As String
Firstname = Trim(txtFirstname.Text)
Lastrow = Worksheets("Portal").Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To Lastrow

If LCase(Worksheets("Portal").Cells(i, 2).Value) = LCase(Firstname) Then
txtFirstname.Text = Worksheets("Portal").Cells(i, 2).Value
TxtSurname.Text = Worksheets("Portal").Cells(i, 3).Value
TxtDOB.Text = Worksheets("Portal").Cells(i, 5).Value
Gender.Text = Worksheets("Portal").Cells(i, 4).Value
Age.Text = Worksheets("Portal").Cells(i, 6).Value
MemberSince.Text = Worksheets("Portal").Cells(i, 7).Value
Years.Text = Worksheets("Portal").Cells(i, 8).Value
Status.Text = Worksheets("Portal").Cells(i, 9).Value
Membership.Text = Worksheets("Portal").Cells(i, 1).Value
FEESpaid.Text = Worksheets("Portal").Cells(i, 11).Value
PaidDate.Text = Worksheets("Portal").Cells(i, 12).Value
FeesDue.Text = Worksheets("Portal").Cells(i, 13).Value

End If
Next


End Sub


Thank you in advance for your consideration and help.

regards

Ged
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi, @GedSalter
Could you upload a sample workbook (without sensitive data) to a sharing site like dropbox.com or google drive? And then share the link here.
This will make it easier to test & find a solution.
In the mean time, here’s an example of a searchable listbox.
userform-searchable-listbox-1-textbox.xlsm
In the textbox type the keywords.
The search ignores the keywords order, so the keyword "ma la" would match "Maryland"
and "Alabama"
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,195
Members
452,616
Latest member
intern444

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