View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mark Driscol[_2_] Mark Driscol[_2_] is offline
external usenet poster
 
Posts: 75
Default macro to delete on a condition

UCase(Cells(i, "c")), which capitalizes every letter, will never equal
"delete", which has all lower-case letters. Try UCase(Cells(i, "c")) =
"DELETE".

Also, "EntireRow.Delete" be something like "Rows(i).EntireRow.Delete".


Mark



Todd wrote:
Hi,

I am trying to delete entire rows based on a condition. My condition is
simple, I put the word "delete" in column b of the worksheet. If it has
"delete" then wa lah! Its supposed to be gone. Except I can't figure out
how to get it done. I've tried a different criteria with putting in a number
instead but I am useless here. Please help?

Todd

Sub deleteif()
On Error Resume Next
For i = Cells(Rows.Count, "a").End(xlUp).Row To 1 Step -1
If UCase(Cells(i, "c")) = "delete" Then
EntireRow.Delete
End If
Next i
End Sub