# Code to delete rows (need help adjusting)

#### thewiseguy

##### Well-known Member
Hi everyone,

Here is my code to delete all rows with value "0" in column C.

Sub DeleteRowOnCell7()
For i = 450 To 1 Step -1
If Cells(i, "C").Value = "0" Then Rows(i).EntireRow.Delete
Next i
End Sub

At the end of all of my data. I have 2 rows worth of totals. The problem I am having is that once the code is run, there is a big gap between my data and my totals of all the data. Is there a way to get the totals (in rows 456 and 457) to move upward as the "0" value cells are deleted?

### Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

#### Lewiy

##### Well-known Member
Code:
``````Sub DeleteRowOnCell7()
For i = 450 To 1 Step -1
If Cells(i, 3).Value = "0" Then Rows(i).Delete Shift:= xlUp
Next i
End Sub``````

#### thewiseguy

##### Well-known Member
Code:
``````Sub DeleteRowOnCell7()
For i = 450 To 1 Step -1
If Cells(i, 3).Value = "0" Then Rows(i).Delete Shift:= xlUp
Next i
End Sub``````

Hi,

I tried this code, but I am still having the same problem.

#### Lewiy

##### Well-known Member
Are you looking at a value zero or a text string “0”? If the former then try:
Code:
``````Sub DeleteRowOnCell7()
For i = 450 To 1 Step -1
If Cells(i, 3) = 0 Then Rows(i).Delete Shift:= xlUp
Next i
End Sub``````

Replies
0
Views
237
Replies
1
Views
363
Replies
4
Views
389
Replies
2
Views
1K
Replies
20
Views
5K

1,191,219
Messages
5,985,328
Members
439,958
Latest member
qb0000

### 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.

### Which adblocker are you using?

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

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