VBA delete rows based on criteria

Katy Jordan

Well-known Member
Joined
Jun 28, 2008
Messages
596
Hi, i am after a vba code that will delete row if there is a string in Col M and then delete row if there is a 0 in Col L


Excel Workbook
LM
4AmountString
56271#N/A
60#N/A
73630#N/A
81320#N/A
90#N/A
100#N/A
11500#N/A
121210#N/A
132000#N/A
140#N/A
15800BUCKINGIND2
16660#N/A
17715#N/A
18110#N/A
190#N/A
203920CORDA
21900#N/A
220#N/A
230#N/A
Sheet29
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
How about something like this...

Please test on a test set of data before implementing.

Code:
Sub DelRows()
    Application.ScreenUpdating = False
    With Range("M4", Range("M" & Rows.Count).End(xlUp))
        .AutoFilter field:=1, Criteria1:="<>#N/A"
        .Offset(1).EntireRow.Delete
        .AutoFilter
    End With
    With Range("L5", Range("L" & Rows.Count).End(xlUp))
        .Replace what:="0", replacement:="", lookat:=xlWhole
        .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,448
Members
452,915
Latest member
hannnahheileen

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