VBA 查找值所在的行号

目录
Function FindRowOfValue(ws As Worksheet, val As Variant, colNum As Long, startRow As Long)
    Dim r As Long
    With ws
    For r = startRow To .Range(.Cells(startRow, colNum), .Cells(startRow, colNum)).CurrentRegion.Rows.Count()
        If .Cells(r, colNum).Value = val Then
            FindRowOfValue = r
            Exit Function
        End If
    Next
    End With
End Function