How To Find Row Position of a Particular Text

Sometimes in Excel, we need to find the row position of a particular text, maybe to be able to paste certain of data right below the corresponding text or else.

Very useful if we have an Excel Worksheet Template that we use a lot, with fix header on it.

' Input param: Text we want to look for
' Optional input params:
'     Search direction (forward, backward),
'     Search order (in row or column)
' Output: row position of the text being searched

Private Function pFindRowPos(sText As Variant, _
  Optional SearchDirection As XlSearchDirection = xlNext, _
  Optional SearchOrder As XlSearchOrder = xlByRows) As Long

    Dim lResult As Long, oRg As Range

    Set oRg = Cells.Find(What:=sText, LookIn:=xlValues, _
    LookAt:=xlPart, SearchOrder:=SearchOrder, _
                 SearchDirection:=SearchDirection, _
    MatchCase:=False, SearchFormat:=False)

    If Not oRg Is Nothing Then lResult = oRg.Row

    pFindRowPos = lResult

    Set oRg = Nothing

End Function

FIN.

This entry was posted in Cells and Range and tagged , , , , , , , , , , , , , . Bookmark the permalink.

1,407 Responses to How To Find Row Position of a Particular Text

  1. Pingback: servis char

  2. Pingback: no fax loan

  3. Pingback: instant payday loan

  4. Pingback: ticket swap

  5. Pingback: promoting and celebrating Virginia creativity

  6. Pingback: cumming tree service

  7. Pingback: live coach

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>