Search code examples
excelvbarangeselection-sort

VBA Excel: How to make a selection from fixed cell till text to be found?


I need to make a selection from cell "A8" to a cell that contains the word "endofsample". That word can be anywhere in the worksheet.


Solution

  • This works for me.

    Sub test()
        Set INFO = Cells.Find(What:="endofsample", After:=ActiveCell, LookIn:=xlFormulas, _
                LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False)
        If INFO Is Nothing Then
        Else
        End If
    
        INFO.Select
        Range("A8", ActiveCell).Select
    End Sub