Delete rows if column looks blank

  • Thread starter Thread starter robyn_willson
  • Start date Start date
R

robyn_willson

I need a macro to delete the entire row if the cell in that row in column A:A
looks blank. I need it to check every row. I say "looks" because the cells
will be part of a list, however I would still like them to be deleted if they
have a formula if they look as though nothing is in them... Please help...
 
Sub killum()
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = n To 1 Step -1
If Cells(i, 1).Value = "" Then
Cells(i, 1).EntireRow.Delete
End If
Next
End Sub
 
This makes it check them inifinitely so the macro never stops. Why does this
happen? Is there a way to fit it?
 
Probably by modifying to look something like this:

Sub killum()
n = Cells(Rows.Count, 1).End(xlUp).Row
While (n >= 1)
If Cells(n, 1).Value = "" Then
Cells(n, 1).EntireRow.Delete
n = n - 1
End If
Wend
End Sub

HTH,

Eric
 
Actually, Gary's code should work just fine (upon actually looking at it!).
It should not create an infinite loop situation. Please check to ensure you
got the "Step -1" part in your code - if you have "Step 1" or nothing at all,
the loop will go on forever.
 
Back
Top