delete rows that have formulas that equal 0

andymalan

Board Regular
Joined
Feb 22, 2017
Messages
128
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
hello everyone

i have a number of rows in a worksheet and most of the cells in each row has a formula that returns the value 0.
i need to delete the entire row if the cell in column A of the row is 0.
my search has brought me to the code below, that also does not work.
Code:
    Dim LastRow As Long
    Dim i As Long
last = Cells(Rows.Count, "A").End(xlUp).Row

'Delete rows
    For i = last To 2 Step -1
        If (Cells(i, "A").Value) = 0 Then
                Cells(i, "A").EntireRow.Delete
        End If
    Next i
any help will be greatly appreciated[/code]
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
About how many rows of data in your worksheet?
 
Upvote 0
About how many rows of data in your worksheet?
Hi Peter
i have 1500 rows and 41 columns, each cell has a formula.
after data is imported from another wkb, many cells return a 0 as the source cell is empty/blank.
 
Upvote 0
Thanks. Give this a try in a copy of your workbook.

VBA Code:
Sub Del_0_in_col_A()
  With ActiveSheet.UsedRange
    .AutoFilter Field:=1, Criteria1:="0"
    .Offset(1).EntireRow.Delete
    .Parent.AutoFilterMode = False
  End With
End Sub
 
Upvote 0
Purrrrrfect Peter, and a million thanks to you.

kind regards
Andy
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,757
Members
449,094
Latest member
dsharae57

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