Delete all rows below The word Page: 2 of 25

D

Duncan J

Need to delete all rows below the word Page: 2 of 25
Do to the report it could be at any row however it usually is in cell
Need to clean up the junk in a macro I sort by part but thiers trash below. Even tried to filter but it won't filter out

Thanks
DJ
 
O

Otto Moehrbach

Do you mean that in some cell you have "Page: 2 of 25"? And it usually is
in Column V? But not always?
One way:
Sub DeleteRows()
Dim FoundCell As Range
Set FoundCell = ActiveSheet.UsedRange. _
Find(What:="Page: 2 of 25", LookAt:=xlWhole)
On Error GoTo NotFound
Range("A" & FoundCell.Row + 1, Range("A" & Rows.Count)). _
EntireRow.Delete
On Error GoTo 0
Exit Sub
NotFound:
On Error GoTo 0
MsgBox "Text not found."
End Sub
Duncan J said:
Need to delete all rows below the word Page: 2 of 25.
Do to the report it could be at any row however it usually is in cell V
Need to clean up the junk in a macro I sort by part but thiers trash
below. Even tried to filter but it won't filter out.
 
D

Duncan J

That works great. I needed to delete the text Page: 2 of 25. I did a find replace on that and stuck it in the macro
I sorted my part number so all above the text Page: 2 of 25 is great and the junk below needs to be deleted. This worked for me
Thanks
DJ
 
O

Otto Moehrbach

Duncan
The FoundCell is the cell than contains the text you searched for. You
don't need to Find/Replace it to clear it. If you want to delete that text,
just say:
FoundCell.ClearContents
Glad it worked for you. Otto
Duncan J said:
That works great. I needed to delete the text Page: 2 of 25. I did a find
replace on that and stuck it in the macro.
I sorted my part number so all above the text Page: 2 of 25 is great and
the junk below needs to be deleted. This worked for me!
 
Top