Filling all those cells with zeroes seem wasteful and inefficient; however, if that is what you have, then give this code a try...Yes, All cells. 1 to last cell. A:A
Sub DeleteRows()
If Application.CountIf(Columns("A"), 0) = Rows.Count Then Range("A6:D" & Rows.Count).ClearContents
End Sub
Unfortunately does not work! i need is if total column A = 0Filling all those cells with zeroes seem wasteful and inefficient; however, if that is what you have, then give this code a try...
Code:Sub DeleteRows() If Application.CountIf(Columns("A"), 0) = Rows.Count Then Range("A6:D" & Rows.Count).ClearContents End Sub
Unfortunately does not work! i need is if total column A = 0
If this condition is met is executed code.
I want total cells, not every cell. if SUM(A:A)=0But that is what my code does.. if every cell in Column A equals a zero (from A1 down to A1038576), then A6:D1038576 is cleared, otherwise nothing happens. If that is not working for you, then there is something different about your cells that you are not telling us. Another possibility, I guess, is if you have a Change event procedure that fills in blank cells... that would kick in after my macro runs and "undo" things.
Sub DeleteRows()
If Application.Sum(Columns("A")) = 0 Then Range("A6:D" & Rows.Count).ClearContents
End Sub
Excellent, works successfully!Sorry, I misunderstood your response to my question. Give this code a try then...
Code:Sub DeleteRows() If Application.Sum(Columns("A")) = 0 Then Range("A6:D" & Rows.Count).ClearContents End Sub