Search 2 criteria in ListBox in UserForm after it is populated

Hasegawa

New Member
Joined
Oct 31, 2018
Messages
10
Dear All Masters,

My Code:

Private Sub Search_Click()

Dim x1, i As Long, ii As Long, iii As Integer
x1 = [myCar]
Application.ScreenUpdating = False
With ListBox1
If TextBox2 = "" Then
.RowSource = "myCar"
Else
.RowSource = ""
For i = 1 To UBound(x1, 1)
If LCase(x1(i, 2)) Like LCase(TextBox2) & "*" Then 'Search location column 2

For ii = 1 To 10
.AddItem
.List(iii, ii - 1) = x1(i, ii)
Next
iii = iii + 1
End If
Next
End If
End With
End Sub

"Search" is CommandButton
"myCar" is name range from A:J (10 columns) in sheet1 and it is RowSource in ListBox1
"TextBox2" is for input searching criteria

When I open UserForm1 , I have another code to sync RowSource("myCar") into ListBox1. After that I can search data in ListBox1 once it is populated.

Above code is for searching data in ListBox1 with single criteria in TextBox2.My code can search data in ListBox1 which is based on criteria in column 2 in RowSource("myCar")

=> My problem :
I want to search data in ListBox1 (After populated) with 2 criteria :
TextBox2.value = 1st criteria which is the data in column 2 in range("myCar")
TextBox3.value = 2nd criteria which is the data in column 3 in range("myCar")

Pls kindly help me Sir/Madam !!!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,215,831
Messages
6,127,140
Members
449,362
Latest member
Bracelane

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