Delete rows if cell in column H is zero

MOB

Well-known Member
Joined
Oct 18, 2005
Messages
1,055
Office Version
  1. 365
Platform
  1. Windows
Data is in rows 2:3001

If the value in column H of each row is zero I need the entire row deleting.

Code:
Sub DeleteRows()

Dim ChkRange As Range
Set ChkRange = Range("H2:H3001")

Dim cell As Range

For Each cell In ChkRange
    If cell = "0" Then
        cell.EntireRow.Delete
    End If
Next

End Sub

I thought the above would work but it seems to only remove a couple of rows, where most of them should be deleted!!

TIA
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Are the zeros values, or the result of a formula?
 
Upvote 0
Initially on another tab calculated using a formula, but paste special-values into the above spreadsheet
 
Upvote 0
In that case, try
Code:
Sub DeleteZeros()

With Range("H2:H3001")
   .Replace 0, "=XXX", xlWhole, , , , False, False
   On Error Resume Next
   .SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
   On Error GoTo 0
End With
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,217
Members
448,876
Latest member
Solitario

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