Search and list with look at part and matchcase false

LittleRedOne

New Member
Joined
Nov 28, 2013
Messages
4
Hi All,

I have a userform with a textbox (TbAdd6) and a cmd button. I have managed to search and list all the matches, in a new userform containing a listbox, using the cmd button and this works fine. However it will only find exact matches from the data entered in the textbox. How can work it so that it will display the results of a part match and not be case sensitive? Please can somebody help?

My code is as follows

Private Sub CommandButton17_Click()
Dim dataRange As Range
Dim oneCell As Range

With Sheets("Database").Range("B:B")
Set dataRange = Range(.Cells(1, 1), .Cells(Rows.Count, 1).End(xlUp))
End With
UserForm9.ListBox1.Clear
For Each oneCell In dataRange
With oneCell.EntireRow
If CStr(.Range("G1").Value = UserForm1.TbAdd6.Value) Then
UserForm9.ListBox1.AddItem CStr(.Range("B1").Value)
UserForm9.ListBox1.List(UserForm9.ListBox1.ListCount - 1, 1) = CStr(.Range("C1").Value)
UserForm9.ListBox1.List(UserForm9.ListBox1.ListCount - 1, 2) = CStr(.Range("D1").Value)
UserForm9.ListBox1.List(UserForm9.ListBox1.ListCount - 1, 3) = CStr(.Range("E1").Value)
UserForm9.ListBox1.List(UserForm9.ListBox1.ListCount - 1, 4) = CStr(.Range("F1").Value)
UserForm9.ListBox1.List(UserForm9.ListBox1.ListCount - 1, 5) = CStr(.Range("G1").Value)
UserForm9.ListBox1.List(UserForm9.ListBox1.ListCount - 1, 6) = .EntireRow.Address(, , , True)
End If
End With
Next oneCell
UserForm9.Show
End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,215,639
Messages
6,125,971
Members
449,276
Latest member
surendra75

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