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,
 

Some videos you may like

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
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
 

Oeldere

Well-known Member
Joined
Dec 29, 2011
Messages
2,213
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
 

Massedamha

New Member
Joined
Nov 17, 2012
Messages
4
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
 

Massedamha

New Member
Joined
Nov 17, 2012
Messages
4

ADVERTISEMENT

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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,773
Messages
5,598,010
Members
414,204
Latest member
Excelmee

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