Worksheet Search – Get Element Start Row
Searches for a specific text value in a given column of an Excel.Worksheet and returns the row number where it is found.
Uses the Find method on the specified column to locate the first occurrence of the text.
VB
Public Function xlGetElementStartRow(TextToSearch As String,
ColumnToSearch As Integer,
wsSheet As Excel.Worksheet) As Integer
'Search start row in Project DB
Dim erIDs As Excel.Range = wsSheet.Columns(ColumnToSearch)
Try
Return erIDs.Find(TextToSearch).Row
Catch ex As Exception
Return 0
End Try
End Function