Select a range of cells in a single column for the rows you want to evaluate,
then run this code:
Dim lastRow As Long, R As Long
Application.ScreenUpdating = False
lastRow = Selection.Row - 1 + Selection.Rows.Count
For R = lastRow To Selection.Row Step -1
If Application.Sum(Rows(R)) = 0 Then Rows(R).Delete
Quote:>I'm trying to write a macro to delete all rows in a worksheet when the sum of
>the values in the rows equals zero. I have a file with several tabs (one for
>each department). Each row represents an account number. Each tab has all the
>same account numbers. Not all of the account numbers have values.
1. VBA code to delete row based on vaule of one cell within that row?
I am writing a little macro in Excel 97 and I have hit a little block.
I am sure this is do-able, I just lack the knowledge.
I have a cell (well actually I have a worksheet full of cells, but I
think I can work out the looping from one cell to the next...) that
contains a numerical value that is either positive or negative.
If the value is 0 or negitive I want the macro to delete the entire row.
Any suggestions? Thanks in advance!
3. VBA code to delete entire row based on missing value
5. Vba Code Required for Delete Entire Row
6. Problem with Cisco 761. Please help!
7. Macro to delete certain rows
8. Implementation Class Sub-Item : Mandatory or not ?
9. looking for a simple macro to delete certain rows (records)
10. VBA code automatic typesetting and show code row number
11. Can't use a custom VBA function inside VBA code
12. Deleting Every 25th Row Using VBA
13. Excel 97 - deleting rows with VBA