Delete Row if Cell has a 0 value

gottimd

Well-known Member
Joined
Jul 29, 2002
Messages
501
I want the Macro to look in the column c6:c224, and if the cell has a zero value it deletes that row, but cycle through all the cells in c6 through c224 in doing that, not just to stop after the first one.

Can anyone help out?
 
unnameable said:
I think I know what's wrong....

If, for example, it finds 0 at cell A1, it'll delete the row and then move to cell A2. It doesn't recognise that the value that was previously in A2 is now in A1, if you get what I mean.

How can this be worked around?

Oops! Nice catch. Apparently when I breezed through a "test" when writing that, I didn't have any rows with zero together :oops:
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi,

Ok, this seems pretty simple, unless I'm missing something, this should do it.


Sub DeleteZero()

Dim intEnd As Integer

intEnd = 224

Range("C6").Select

Do Until ActiveCell.Row = intEnd

If Int(ActiveCell.Value) = 0 Then
Range(ActiveCell.Row & ":" & ActiveCell.Row).Delete
intEnd = intEnd - 1
Else
ActiveCell.Offset(1, 0).Select
End If

Loop


End Sub


This will not go to row 224 if you are deleting rows, but reduce the end row if rows are deleted.

Peace,
Joshua
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,217
Members
453,024
Latest member
Wingit77

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