Hi all,
The code below (part of a larger macro) searches for the text 'Journey End Event' in column E and deletes all the rows after it. However sometimes, the text 'Journey End Event' is not present and as expected and error occurs. My question is, how can I modify it so that If 'Journey End Event' is not found then Exit Sub?
All help appreciated
John
The code below (part of a larger macro) searches for the text 'Journey End Event' in column E and deletes all the rows after it. However sometimes, the text 'Journey End Event' is not present and as expected and error occurs. My question is, how can I modify it so that If 'Journey End Event' is not found then Exit Sub?
All help appreciated
John
Code:
Sub journey()
..............
'Delete all rows after Journey end event
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
...............
End Sub