Why to textbox can not search Uppercase

Pisitju

New Member
Joined
Dec 8, 2020
Messages
20
Office Version
  1. 365
Platform
  1. Windows
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
Bad.png


but search to Uppercase not found (picture2)
picture2
bad1.png


and barcode

AMR95D31Lแบตเตอรี่ อเมร่อน 95D31L3400
AMR95D31Rแบตเตอรี่ อเมร่อน 95D31R3400
AMR105D31Lแบตเตอรี่ อเมร่อน 105D31L3800
AMR105D31Rแบตเตอรี่ อเมร่อน 105D31R3800
AMR115D31Lแบตเตอรี่ อเมร่อน 115D31L4200
AMR115D31Rแบตเตอรี่ อเมร่อน 115D31R4200

Please help me.

Thank you everyone for anwser
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Change this line of code from
If LCase(Mid(sh.Cells(i, 2), x, a)) = Me.TextBox1 And Me.TextBox1 <> "" Then

To
If LCase(Mid(sh.Cells(i, 2), x, a)) = LCase(Me.TextBox1) And Me.TextBox1 <> "" Then
 
Upvote 0
Solution

Forum statistics

Threads
1,215,092
Messages
6,123,064
Members
449,090
Latest member
fragment

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