GetFirstInstanceInExcel

From scripting
Jump to: navigation, search
Function GetFirstInstanceInExcel(InputVal As String, ColumnNo As Integer, EndRow As Integer) As Integer
Dim LCounter As Integer
LCounter = 2
While LCounter <= EndRow
    CurCellStr = CStr(CurCells(LCounter, ColumnNo).Value)
    If CurCellStr = InputVal Then
        GetFirstInstanceInExcel = LCounter
        Exit Function
    End If
    LCounter = LCounter + 1
Wend
GetFirstInstanceInExcel = -1
End Function