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
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
ElseIf TypeName(Target) = "String" Then
If InStr(1, Target, strSearchFor, vbTextCompare) > 0 Then TextExtract = strSearchFor
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...
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...