View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Sam Wilson Sam Wilson is offline
external usenet poster
 
Posts: 523
Default Delete Row if value <

It's case sensitive, so "DEFECTIVE" is < "Defective".

use if lcase(c.value)="defective"

Sam

"Aaron" wrote:

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