If you have to search an exact match for a String in an Excel worksheets row, the following function might be of help.

Source Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
' @Author - Alexander Bolte
' @Description - Searches for an exact match for a provided String in an Excel sheets row.
' @Param ws - an Excel Worksheet to search.
' @Param searchRow - a row in a provided sheet to search.
' @Param searchStr - a String to search for.
' @Returns the column index an exact match was found in as Integer.
Public Function searchColXlWhole(ByVal ws As Worksheet, ByVal searchRow As Long, ByVal searchStr As String) As Integer
    Dim col As Integer
    Dim foundOne As Object
    
    Set foundOne = ws.Rows(searchRow).EntireRow.Find(searchStr, , xlValues, xlWhole, xlByColumns, xlNext, True, False)
    If Not (foundOne Is Nothing) Then
        col = foundOne.Column
    End If
    
    searchColXlWhole = col
End Function