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 !!!
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 !!!