By using expertatexcel.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

expertatexcel.com

 


FindDataRow

Function FindDataRow(sSearch, c As Long) As Long
'Version: 1.002
' 1.002 Change search from xlValues to xlFormulas as xlValues doesn't work if column shows number as

  • ' 1.001 Speed up using Find insted of for - next
    'Purpose: This program finds the passed sSearch in column c
    ' and returns the row or 0 if not found. Finds the first Exact match
        On Error Resume Next
        ActiveSheet.Cells(4, c).Select
        ActiveSheet.Columns(c).Select
        Selection.Find(What:=sSearch, After:=ActiveCell, LookIn:=xlValues, LookAt _
            :=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase _
            :=False, SearchFormat:=False).Activate
        If Err = 0 Then
            FindDataRow = ActiveCell.Row
        Else
            FindDataRow = 0
        End If
        
    End Function

  •