I created this macro to delete rows with a 0 value on Column 5, starting on Row6. It should stop on the Row with an empty cell on Column 2.
My data has about 600 rows only. However, after Row 20 or so, the spreadsheet just kept waiting and I need to press Esc Key to stop it. When it stops, it is at the last row but it does not do the last part that is to sum column 4.
If I press the macro again, it works fine with the new data and adds the sum in column 4. (by the way, it is my first macro in excel).
Sub DeleteRows()
'
' DeleteRows Macro
' Keyboard Shortcut: Ctrl+d
'
Cells(6, 5).Select
Do While (Cells(ActiveCell.Row, 2) <> "")
Do While (Cells(ActiveCell.Row, 5) = 0)
Rows(ActiveCell.Row).Select
Selection.Delete Shift:=xlUp
Loop
Cells(ActiveCell.Row + 1, 5).Select
Loop
Cells(ActiveCell.Row, 4).Select
Dim cel1 As String, cel2 As String
cel1 = ActiveCell.Offset(-1, 0).End(xlUp).Address
cel2 = ActiveCell.Offset(-1).Address
ActiveCell.Value = "=sum(" & (cel1) & ":" & (cel2) & ")"
End Sub