S
Stan
I need to loop the code below to find all instances within a spreadsheet.
Can anyone help me with this?
Sub cleanup()
On Error GoTo Err
lr = Cells(Rows.Count, 1).End(xlUp).Row + 1
'MsgBox lr
r1 = Cells.Find(What:="use start", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Row
'MsgBox r1
r2 = Cells(r1, 1).End(xlDown).Row + 1
'MsgBox r2
Rows(r2).Resize(lr - r2).Delete
r3 = Cells.Find(What:="Agent:", After:=Cells(r1 - 1, 1), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False, SearchFormat:=False).Row + 2
'MsgBox r3
Rows(r3).Resize(r1 - r3).Delete
Rows(1).Resize(r3 - 4).Delete
Err:
End Sub
Can anyone help me with this?
Sub cleanup()
On Error GoTo Err
lr = Cells(Rows.Count, 1).End(xlUp).Row + 1
'MsgBox lr
r1 = Cells.Find(What:="use start", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Row
'MsgBox r1
r2 = Cells(r1, 1).End(xlDown).Row + 1
'MsgBox r2
Rows(r2).Resize(lr - r2).Delete
r3 = Cells.Find(What:="Agent:", After:=Cells(r1 - 1, 1), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False, SearchFormat:=False).Row + 2
'MsgBox r3
Rows(r3).Resize(r1 - r3).Delete
Rows(1).Resize(r3 - 4).Delete
Err:
End Sub