Consulting

Results 1 to 2 of 2

Thread: Sleeper: Selecting rows in between 2 speicific words

  1. #1

    Sleeper: Selecting rows in between 2 speicific words

    hi there , is there some way which i can select all the row inbetween 2 specific words ... say onshore , offshore , on and off shore ..

    thanks in advance

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this:

    Option Explicit 
     
    Sub SelectRange()
    Dim FirstRow        As Long
        Dim LastRow         As Long
    On Error Resume Next
        FirstRow = Cells.Find(What:="On Shore", After:=Range("IV65536"), LookIn:=xlValues, LookAt:= _
        xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext).Row
    LastRow = Cells.Find(What:="Off Shore", After:=Range("A1"), LookIn:=xlValues, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        On Error GoTo 0
    If FirstRow > 0 And LastRow > 0 Then
            Range("A" & FirstRow + 1 & ":IV" & LastRow - 1).Select
        End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •