ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Delete all rows below certain value on multiple worksheets? (https://www.excelbanter.com/excel-discussion-misc-queries/171688-delete-all-rows-below-certain-value-multiple-worksheets.html)

[email protected]

Delete all rows below certain value on multiple worksheets?
 
Hello,

I searched and tried myself, but to no avail on how to do this.

I want to delete all rows below a certain value on multiple worksheets
(I am importing multiple text files @ once).

I need to delete all rows below the phrase "detail as follows".

I can't just delete the rows by highlighting all worksheets at once as
each different worksheet has the phrase "detail as follows" on
different lines.

Any ideas?

Ron de Bruin

Delete all rows below certain value on multiple worksheets?
 
Try this for one worksheet (Sheet1), it look in the A column
If it is working OK then we can make a loop through all sheets

Sub Find_Test()
Dim FindString As String
Dim Rng As Range
FindString = "detail as follows"
With Sheets("Sheet1").Range("A:A")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Rng.Parent.Rows(Rng.Row + 1 & ":" & Rng.Parent.Rows.Count).Delete
Else
MsgBox "Nothing found"
End If
End With
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message ...
Hello,

I searched and tried myself, but to no avail on how to do this.

I want to delete all rows below a certain value on multiple worksheets
(I am importing multiple text files @ once).

I need to delete all rows below the phrase "detail as follows".

I can't just delete the rows by highlighting all worksheets at once as
each different worksheet has the phrase "detail as follows" on
different lines.

Any ideas?



All times are GMT +1. The time now is 02:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com