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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
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,224,872
Messages
6,181,498
Members
453,047
Latest member
charlie_odd

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