Macro to delete entire row if a cell in column m has number zero.

sara2009

New Member
Joined
Apr 1, 2013
Messages
16
Hi everyone,,
IN great need of a code to delete ENTIRE ROW if a cell in COLUMN M has number 0.
my range is from row 2 to row 3745, and there is blank row every after 34 rows. for example there is data from ROW 2 TO ROW 35 then there is blank row and so on.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try

Code:
Sub test()
Dim LR As Long, i As Long
LR = Range("M" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For i = LR To 1 Step -1
    If Range("M" & i).Value = 0 Then Rows(i).Delete
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Code:
Option Explicit
Sub DeleteRow()
Dim i As Integer
For i = 3745 To 2 Step -1
    If Not IsEmpty(ActiveSheet.Cells(i, 13)) And _
        ActiveSheet.Cells(i, 12) = 0 Then ActiveSheet.Cells(i, 13).EntireRow.Delete
    
Next i
End Sub

This won't delete your empty rows.
 
Last edited:
Upvote 0
HELOO mrexcelMVP it worked but it deleted ALL my empty rows... please give me a code that will not delete my empty rows. i just need a code to delete rows with a number 0 in column M..
 
Upvote 0
Sorry, try

Code:
Sub test()
Dim LR As Long, i As Long
LR = Range("M" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For i = LR To 1 Step -1
    If Range("M" & i).Value = 0 And Range("M" & i).Value <> "" Then Rows(i).Delete
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Code:
Option Explicit
Sub DeleteRow()
Dim i As Integer
For i = 3745 To 2 Step -1
    If Not IsEmpty(ActiveSheet.Cells(i, 13)) And _
        ActiveSheet.Cells(i, 12) = 0 Then ActiveSheet.Cells(i, 13).EntireRow.Delete
    
Next i
End Sub

This won't delete your empty rows.

^^^^^^^^^^^^^^^^^^^^^
 
Upvote 0
heloo nuked thanks,but i inserted the code nothing happend.....no row was deleted ..please help me fix it.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,967
Members
452,371
Latest member
Frana

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