View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Aaron Aaron is offline
external usenet poster
 
Posts: 287
Default Delete Row if value <

Worked great except it deleted the header row??
How can I change it?

"Ron de Bruin" wrote:

Hi Aaron

Check out this page for example code
http://www.rondebruin.nl/delete.htm

When you delete rows always start at the bottom and go up

--

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


"Aaron" wrote in message ...
I have the following code that should delete any row that doesn't have the
value of Defective in my range but it is deleting everything. Please help.

lastrow = Cells(Rows.Count, "A").End(xlUp).Row

For Each c In ActiveSheet.Range("C2:C" & lastrow)
If c.Value = "DEFECTIVE" Then
Else
Selection.EntireRow.delete
End If
Next

Thanks in advance, Aaron