Pages

Sunday, March 11, 2012

search text in excel cell

myint=instr(1,activecell.value,"Abc")
which is going to return a number to where "Abc" starts

if myint > 0
text found.
----------------------------------------------------------------------
Function TextSearch(ByVal strSearchFor, ByVal Target As Variant) As Boolean
Dim OneCell As Range

TextSearch = False
If TypeName(Target) = "Range" Then
For Each OneCell In Target
If InStr(1, OneCell.Text, strSearchFor, vbTextCompare) > 0 Then
TextSearch = True
Exit For
End if
Next OneCell
ElseIf TypeName(Target) = "String" Then
If InStr(1, Target, strSearchFor, vbTextCompare) > 0 Then TextSearch = True
End If

End Function


------------------------------------------------------------------------------

Reference:
1. http://www.eng-tips.com/viewthread.cfm?qid=127459

0 comments:

 

site weekly hits