Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Code to delete rows based on value
I have the following code that will delete all rows that DO NOT contain the value "11327" in column A. I need to expand this code to include roughly 40 values.
Here is what I have: Sub delete_It() Dim MyRange1 As Range Dim MyRange As Range lastrow = Cells(Rows.Count, "A").End(xlUp).Row Set MyRange = Range("A1:A" & lastrow) For Each c In MyRange If InStr(1, UCase(c.Value), "11327", 0) Then If MyRange1 Is Nothing Then Set MyRange1 = c.EntireRow Else Set MyRange1 = Union(MyRange1, c.EntireRow) End If End If Next If Not MyRange1 Is Nothing Then MyRange1.Delete End If End Sub Any help will be greatly appreciated. Thanks, DFB |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Delete Rows based on # of rows (no variable?) | Excel Programming | |||
Delete Rows based on value | Excel Worksheet Functions | |||
Code for Excel 2007 to hide rows based on sum of several rows not ina range | Excel Programming | |||
Code help, delete rows based on column criteria | Excel Discussion (Misc queries) | |||
Delete rows based on value... | Excel Programming |