Hi there,
The code below which is part of a larger macro looks for the text 'Journey End Event' in column E and deletes all rows below it. However, sometimes this text in not present and an error occurs. My question is how can I modify it so that if 'Journey End Event' is not found then exit the journey function. The journey function is called inside another function, so if the text is not present then I want it to Exit sub.
Thank you
The code below which is part of a larger macro looks for the text 'Journey End Event' in column E and deletes all rows below it. However, sometimes this text in not present and an error occurs. My question is how can I modify it so that if 'Journey End Event' is not found then exit the journey function. The journey function is called inside another function, so if the text is not present then I want it to Exit sub.
Thank you
Code:
Journey()
Dim LastRow2 As Long, myCell As Range, myRange As Range
Dim myCell1 As Range
***********Other code************
LastRow2 = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
Set myCell1 = Range("E" & LastRow2)
Cells.Find(What:="Journey End Event", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
Set myCell = ActiveCell(2, 0)
Set myRange = Range(myCell, myCell1)
myRange.EntireRow.Delete
*************other code***************
End sub