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.PublicFunctionsearchColXlWhole(ByValwsAsWorksheet,ByValsearchRowAsLong,ByValsearchStrAsString)AsIntegerDimcolAsIntegerDimfoundOneAsObjectSetfoundOne=ws.Rows(searchRow).EntireRow.Find(searchStr,,xlValues,xlWhole,xlByColumns,xlNext,True,False)IfNot(foundOneIsNothing)Thencol=foundOne.ColumnEndIfsearchColXlWhole=colEndFunction