Hi everyone I have a problem.
Textbox in userform can not search Uppercase but search lowercase only
Please help me.
Now VBA code
Private Sub TextBox1_Change()
Dim sh As Worksheet
Set sh = Sheets("Product")
Dim i As Long
Dim x As Long
Dim a As Long
Me.ListBox1.Clear
Me.ListBox1.Additem "PRODUCT NAME"
Me.ListBox1.List(ListBox1.ListCount - 1, 1) = "PRICE"
Me.ListBox1.Selected(0) = True
For i = 2 To sh.Range("C" & Rows.Count).End(xlUp).Row
For x = 1 To Len(sh.Cells(i, 2))
a = Me.TextBox1.TextLength
If LCase(Mid(sh.Cells(i, 2), x, a)) = Me.TextBox1 And Me.TextBox1 <> "" Then
With Me.ListBox1
.Additem sh.Cells(i, 2)
.List(ListBox1.ListCount - 1, 0) = sh.Cells(i, 3)
.List(ListBox1.ListCount - 1, 1) = sh.Cells(i, 4)
End With
End If
Next x
Next i
End Sub
if you search lowercase can found same picture
picture1
but search to Uppercase not found (picture2)
picture2
and barcode
Please help me.
Thank you everyone for anwser
Textbox in userform can not search Uppercase but search lowercase only
Please help me.
Now VBA code
Private Sub TextBox1_Change()
Dim sh As Worksheet
Set sh = Sheets("Product")
Dim i As Long
Dim x As Long
Dim a As Long
Me.ListBox1.Clear
Me.ListBox1.Additem "PRODUCT NAME"
Me.ListBox1.List(ListBox1.ListCount - 1, 1) = "PRICE"
Me.ListBox1.Selected(0) = True
For i = 2 To sh.Range("C" & Rows.Count).End(xlUp).Row
For x = 1 To Len(sh.Cells(i, 2))
a = Me.TextBox1.TextLength
If LCase(Mid(sh.Cells(i, 2), x, a)) = Me.TextBox1 And Me.TextBox1 <> "" Then
With Me.ListBox1
.Additem sh.Cells(i, 2)
.List(ListBox1.ListCount - 1, 0) = sh.Cells(i, 3)
.List(ListBox1.ListCount - 1, 1) = sh.Cells(i, 4)
End With
End If
Next x
Next i
End Sub
if you search lowercase can found same picture
picture1
but search to Uppercase not found (picture2)
picture2
and barcode
AMR95D31L | แบตเตอรี่ อเมร่อน 95D31L | 3400 |
AMR95D31R | แบตเตอรี่ อเมร่อน 95D31R | 3400 |
AMR105D31L | แบตเตอรี่ อเมร่อน 105D31L | 3800 |
AMR105D31R | แบตเตอรี่ อเมร่อน 105D31R | 3800 |
AMR115D31L | แบตเตอรี่ อเมร่อน 115D31L | 4200 |
AMR115D31R | แบตเตอรี่ อเมร่อน 115D31R | 4200 |
Please help me.
Thank you everyone for anwser