Excel User form (1 Viewer)

zezo2021

Member
Local time
Today, 16:09
Joined
Mar 25, 2021
Messages
381
friends
I'm using this code to search in a specific column in sheet

My problem is:
- Search is Case Sensitive
- I want to search with any part of the word, not from the start

Code:
Dim LastRow As Integer
LastRow = Worksheets("Database").Cells(Rows.Count, 2).End(xlUp).Row
Dim i As Integer
i = 0

For Each C In Worksheets("Data").Range("B2:B" & LastRow)
        If C Like txtSearch.Value & "*" Then

        End If
Next C
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:09
Joined
May 7, 2009
Messages
19,233
Code:
Dim LastRow As Integer
LastRow = Worksheets("Database").Cells(Rows.Count, 2).End(xlUp).Row
Dim i As Integer
Dim C As Range
i = 0

For Each C In Worksheets("Data").Range("B2:B" & LastRow)
        If C.Value & "" Like "*" txtSearch.Value & "*" Then

        End If
Next C
 

zezo2021

Member
Local time
Today, 16:09
Joined
Mar 25, 2021
Messages
381
Code:
Dim LastRow As Integer
LastRow = Worksheets("Database").Cells(Rows.Count, 2).End(xlUp).Row
Dim i As Integer
Dim C As Range
i = 0

For Each C In Worksheets("Data").Range("B2:B" & LastRow)
        If C.Value & "" Like "*" txtSearch.Value & "*" Then

        End If
Next C
is there & before textSearch

error and stop on txtSearch
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:09
Joined
May 7, 2009
Messages
19,233
ooopps, yes there is.

If C.Value & "" Like "*" & txtSearch.Value & "*" Then
 

zezo2021

Member
Local time
Today, 16:09
Joined
Mar 25, 2021
Messages
381
Sorry
worked
But if the sentence begin with Capital Must Type Capital
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:09
Joined
May 7, 2009
Messages
19,233
If InStr(1, C.Value & "", txtSearch.Value, vbBinaryCompare) <> 0 Then

End If
 

Users who are viewing this thread

Top Bottom