L
Lori from Minnesota
Hi,
I have the following macro that runs perfectly, but the number of times it
needs to loop is not always going to be 21. Could someone please tell me how
to modify it so that it continues to loop until it doesn't find any more
instances of [MID BS SA]? What I'm doing is deleted all the extra headers in
a report, but I want the initial, first page header to remain.
Here's my macro:
Range("A1").Select
Cells.Find(What:="MID BS SA", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=True, SearchFormat:=False).Activate
For Counter = 1 To 21
ActiveCell.Select
Cells.Find(What:="MID BS SA", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=True, SearchFormat:=False).Activate
ActiveCell.Offset(-4, 0).Rows("1:10").EntireRow.Select
Selection.Delete Shift:=xlUp
Next Counter
Range("A1").Select
End Sub
Any help you can give will be greatly appreciated.
Thanks so much,
Lori
I have the following macro that runs perfectly, but the number of times it
needs to loop is not always going to be 21. Could someone please tell me how
to modify it so that it continues to loop until it doesn't find any more
instances of [MID BS SA]? What I'm doing is deleted all the extra headers in
a report, but I want the initial, first page header to remain.
Here's my macro:
Range("A1").Select
Cells.Find(What:="MID BS SA", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=True, SearchFormat:=False).Activate
For Counter = 1 To 21
ActiveCell.Select
Cells.Find(What:="MID BS SA", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=True, SearchFormat:=False).Activate
ActiveCell.Offset(-4, 0).Rows("1:10").EntireRow.Select
Selection.Delete Shift:=xlUp
Next Counter
Range("A1").Select
End Sub
Any help you can give will be greatly appreciated.
Thanks so much,
Lori