code to delete "0" values

thewiseguy

Well-known Member
Joined
May 23, 2005
Messages
803
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,

I would like a code that will delete rows (from 14-450) only if they have a "0" value in column c.


Can anyone help?


tia

-m
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Code:
Sub DeleteRows()
For i = 450 To 14 Step -1
    If Cells(i, "C").Value = "0" Then Rows(i).EntireRow.Delete
Next i
End Sub
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
Sub dl()
Dim i As Integer
Application.ScreenUpdating = False
Application.Calculation = xlManual
For i = 450 To 14 Step -1
    If Cells(i, 3).Value = 0 Then Rows(i).Delete
Next i
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub
 

thewiseguy

Well-known Member
Joined
May 23, 2005
Messages
803
Office Version
  1. 365
Platform
  1. Windows
Code:
Sub DeleteRows()
For i = 450 To 14 Step -1
    If Cells(i, "C").Value = "0" Then Rows(i).EntireRow.Delete
Next i
End Sub

great, thank you!!
 

Beate Schmitz

Active Member
Joined
May 20, 2007
Messages
392
Hello,

<div style="background-color:#FFFFFF; border-width:2px; border-style: groove; border-color:#ff9966; padding:4px;"><nobr><span style="font-family:Courier New,Arial; font-size:9pt ;" ><span style="color:#000080"; >Sub</span> delete_zerorows_in_C()
    <span style="color:#000080"; >With</span> Range(<span style="color:#800000"; >"C14:C450"</span>)
        .Replace 0, True, xlWhole
        .SpecialCells(xlCellTypeConstants, 4).EntireRow.Delete
    <span style="color:#000080"; >End</span> <span style="color:#000080"; >With</span>
<span style="color:#000080"; >End</span> <span style="color:#000080"; >Sub</span>

</span></nobr></div>
 

Watch MrExcel Video

Forum statistics

Threads
1,122,567
Messages
5,596,908
Members
414,110
Latest member
docops

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
Top