Thread: Delete Rows
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Delete Rows

Maybe

Sub standard()
Dim myrange, MyRange1 As Range
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set myrange = Sheets("Sheet1").Range("A1:A" & LastRow)
For Each c In myrange
If UCase(c.Value) = "TEST" Then 'Change you your string
LastRow = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
Range("A" & c.Row & ":A" & LastRow).EntireRow.ClearContents
End If
Next
End Sub

Mike

"DougW" wrote:

I would like to write code that would find text in column A and then select
all rows to the last row, and finally delete all the selected rows including
the original row where the text was found.

I am able to find the text, no problem, and the text is unique to the first
column. I used ActiveCell.End(xlDown) to get to the last row. But, it doesn't
select all the rows.

I tried finding the text and then using:

strBeginCell = Selection.Addres

as the beginning address, then using the following to get the ending cell
address:

ActiveCell.End(xlDown).Select
strEndCell = Selection.Address

And, finally using the following to select all the rows, at which point I
get a syntax error:

Range(strBegCell:strEndCell).Select

Thank you.
--
DougW