Hi,
I need to write a macro which checks cells in one column and if the cell is empty it deletes the whole row (which contains the cell).
I tried this code but it doesn't delete all rows with empty cells:
Public Sub deleterows()
For o = 7 To 25
If Worksheets("sheet").Cells(o, 4) = "" Then
Rows(o).Delete
End If
End If
Next o
End Sub
So I modified the code:
Public Sub deleterows()
For o = 7 To 25
If Worksheets("sheet").Cells(o, 4) = "" Then
Rows(o).Delete
o = o - 1
a = a + 1
If a = 20 Then
o = 25
End If
End If
Next o
End Sub
It works correct but it is not a proper solution (it ends the for loop after 20 deleted cells)...
Do you have any better suggestions?
Thanks!
Bookmarks