code to delete "0" values

thewiseguy

Well-known Member
Joined
May 23, 2005
Messages
818
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
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

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
818
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>
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,084
Messages
5,857,265
Members
431,866
Latest member
Paula777

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