Delete a row when cell value equals zero macro

Massedamha

New Member
Joined
Nov 17, 2012
Messages
4
hi all ,
i have and excel sheet which is a compilation of various sheets copied from different sources . i want to delete the rows where their cells in column e equals zero starting from e3 as e2 has a zero value i want to keep.
the sheet that contains that column is named "all data"
thanks a lot and best regards,
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try

Code:
Sub test()
Dim LR As Long, i As Long
With Sheets("all data")
    LR = .Range("E" & Rows.Count).End(xlUp).Row
    For i = LR To 3 Step -1
        If .Range("E" & i).Value = 0 Then .Rows(i).Delete
    Next i
End With
End Sub
 
Upvote 0
Try this one on a copy of your file.

Code:
Sub DeleteValueWith_0_in_column_E()
Dim r As Long
For r = Cells(Rows.Count, 5).End(xlUp).Row To 3 Step -1
If Cells(r, 5) = "0" Then Rows(r).Delete
Next r
End Sub
 
Upvote 0
Thanx alot it worked :D i am so gratefull
Try this one on a copy of your file.

Code:
Sub DeleteValueWith_0_in_column_E()
Dim r As Long
For r = Cells(Rows.Count, 5).End(xlUp).Row To 3 Step -1
If Cells(r, 5) = "0" Then Rows(r).Delete
Next r
End Sub
 
Upvote 0
and this code also worked thanks alot guys for the help
Try

Code:
Sub test()
Dim LR As Long, i As Long
With Sheets("all data")
    LR = .Range("E" & Rows.Count).End(xlUp).Row
    For i = LR To 3 Step -1
        If .Range("E" & i).Value = 0 Then .Rows(i).Delete
    Next i
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,528
Messages
6,120,064
Members
448,941
Latest member
AlphaRino

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