Macro for deleting row with condition [Closed]

- - Latest reply: venkat1926
Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
- Jan 6, 2010 at 09:36 PM
Hello,

I need a Macro for deleting rows when none of the cells in the row contain one of two numbers "103526" or "103527"

the number of rows is variable (max 150) and number of columns variable too (max 100)

any help is appreciated

thanks
See more 

1 reply

Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
784
0
Thank you
Your condition is confusing to me . I am rephrasingit
if a row contains either 103526 or 102527 or both thenf DO NOT delete
if neither of the two numbers is in a row delete
now as you are deleting the rows keep a copy of the data in sheet1 to sheet2 so that you can retiree the dta if there is mess up.

the data is in sheets 1
try this macro

Sub test()
Dim j As Integer, k As Integer
Dim r As Range, cfind6 As Range, cfind7 As Range
Worksheets("sheet1").Activate
On Error Resume Next
j = Cells(Rows.Count, "A").End(xlUp).Row
For k = j To 1 Step -1
Set cfind6 = Rows(k).Cells.Find(what:=103526, lookat:=xlWhole)

Set cfind7 = Rows(k).Cells.Find(what:=103527, lookat:=xlWhole)
If cfind6 Is Nothing And cfind7 Is Nothing Then Rows(k).Delete

Next



please repost if there is any problem