Windows 7 - Using While Wend with Cells.Find

Asked By Billy on 14-Aug-12 12:14 PM
I import data into a worksheet in Excel2007. I want to find the statement "=
Stop by Reason", and delete it and some rows above and below it. It might a=
ppear 1 time, or up to 5 or 6 times. The follwing code will find it, but on=
ce all occurances been found and deleted, I get this messsage...
Run time error '91':
Object variable or With block variable not set.

This is the code...
Sub DeleteStopReason()
While Cells.Find(What:=3D"Stop by Reason", After:=3DActiveCell, LookIn =
_
rection:=3D _
xlNext, MatchCase:=3DFalse, SearchFormat:=3DFalse).Activate
ActiveCell.Offset(-9, 0).Range("A1:A14").Select
Selection.EntireRow.Delete
ActiveCell.Select
Wend
End Sub
I do not understand what must be done to coreect this sothat all occurcnes =
will be deleted and the macro not stop.

Thanks,

Billy




Don Guillett replied to Billy on 14-Aug-12 01:13 PM
appear 1 time, or up to 5 or 6 times. The follwing code will find it, but =
once all occurances been found and deleted, I get this messsage...
n _
Direction:=3D _
s will be deleted and the macro not stop.

Look in the vba help index for FINDNEXT. Try that and post again after if y=
ou still cannot get it.