I have a code which searches a column of text in excel for a student names.
The code I am using is:
Private Sub CommandButton1_Click()
row_number = 0
count_of_string = 0
search_string = Sheets("Names").Range("C3")
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("Names").Range("A" & row_number)
If InStr(item_in_review, search_string) > 0 Then
count_of_string = count_of_string + 1
End If
Loop Until item_in_review = ""
MsgBox (search_string & " occurred: " & count_of_string & " times.")
End Sub
This works fine. The problem I am having is that if the user changes the case of any name while typing it in the search field, the code does not 'see' the name. For instance, if the user searches for "mark" instead of "Mark" as found in the column, the code incorrectly says that it does not exist. How can I re-write this, please?