How to delete entire row based if amount in zero

EagerToLearn

New Member
Joined
Jan 20, 2011
Messages
20
Hello there
I have been asking questions and never turned down, all answers I got back were perfectly correct and served my purpose, so as usual thanks in advance
I have a simple question
In excel sheet that contains data in column A:H with column E for amount
How can I delete the entire row if the dollar amount under column E is zero
Your help is much appreciated
:eek:
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Try something like this....

Code:
Sub DeleteZero()

Col = 5 'Column E
With ActiveSheet  ' or Sheets("Your Sheet Name")
Application.ScreenUpdating = False

  For r = 1 to 10  'Set your own limits for r
      If .Cells (r,Col).Value = 0 Then .Cells(r,Col).EntireRow.Delete 
  Next r
Application.ScreenUpdating = True

End With

End Sub
 
Upvote 0
  • Select column E
  • Select from the menu Data\Filter\Autofilter
  • This will put a dropdown list in cell E1
  • Select from the E1 dropdownlist either zero or "Blanks"
  • This will hide all the rows that are not zero or Blank
  • Select the visible rows and delete
  • Select Autofilter again to turn it off
 
Upvote 0
Hello Alfa,
Thanks a lot for your kind reply, I was looking for VBA code.
Your trick will do and really good help.
Appreciated.
 
Upvote 0
I was looking for VBA code.
If that is still the case and if your values in Column E are constants (that is, there are no formulas in Column E), then you can use this quick code to delete the indicated rows...

Code:
Sub DeleteRowsForZeroesInColumnE()
  Columns("E").Replace 0, "=0", xlWhole
  On Error Resume Next
  Columns("E").SpecialCells(xlCellTypeFormulas).EntireRow.Delete
End Sub
If the values in Column E are not constants (that is, they are formulas, then tell me the row number the formulas start on and I'll adjust the code to handle that situation for you.
 
Last edited:
Upvote 0
Hello Snakehips,
Very good simple code, but I am afraid I might be doing something wrong.
It not deleting every row that have zero on column E.
It is deleting some and letting other without deletion.
I can not tell why.
May be formatting issue.
Like it is not seeing 0.00 as zero dollar
Advise?
 
Upvote 0
If you're using Snakhips code, change this...
Code:
For r = 1 to 10  'Set your own limits for r

To this
Code:
For r = 10 to 1 Step -1  'Set your own limits for r

You need to delete from the bottom up to prevent skipping over consecutive zeros
 
Upvote 0
Hello Rick,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
Hope the storm did not really hit you bad; I lived in NY couple years and visited <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:eek:ffice:smarttags" /><st1:place w:st="on">Jersey</st1:place> couple times<o:p></o:p>
The code you sent is a master piece, it is working just great.<o:p></o:p>
Thanks and have a nice weekend<o:p></o:p>
<o:p> </o:p>
 
Upvote 0
Hello Alfa,
Got it, it is working now, thanks for the time you spent on that.
I am working hard on a big book I bought for VBA programming.
Studying slowly but surely on the right track.
Thanks all for your kind help
 
Upvote 0
@EagerToLearn

First off, you are quite welcome for the code... I'm glad it worked out for you. Second, I live in central NJ and we actually did okay here for the main part. We have a major creek here that set an all-time flood stage record and there were many people who live in its flood plain affected by flooding from it, but we were warned to expect all kinds of havoc from downed trees because of already overly saturated ground around tree roots, but when the storm got to NJ, the winds actually lessened and we were spared that part of the scenario. Unfortunately, those living in northeast NJ got hit quite hard from river flooding (it made nation news here), so I really feel for them though.
 
Upvote 0

Forum statistics

Threads
1,215,943
Messages
6,127,826
Members
449,411
Latest member
adunn_23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top