Hi all
I would like to search a Excel List of names(voters Registration list) by typing a name to see if that person is registered. Can anyone advice me how to do it or provide me with a sample program
Many thanks

5 Years
Discussion Span
Last Post by stillmarooned

Try the following, in your macro -

Function TextExtract(ByVal strSearchFor, ByVal Target As Variant) As String
Dim OneCell As Range

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

End Function

Example Usage (As a worksheet function):

''3b will be the text searched for...

It does not return which cell in the range contains the text. In the case shown only cell A43 contained "3B". This function will search the text sequentially until the condition is true then it will stop searching. Text search will work the same way.

Note that this function is not case sensitive. It will not return how many times the text is present. A modification can be made to have the function count how many cases of the text appear.

Please read more from this link with some more sample code...

Edited by AndreRet


hi Industrious poster
Thanks for the response. I will try it later and get back

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.