Delete Rows based on condition

V

Vic

How do I perform elimination of row based on the following:
If L2 = M2 then leave this row alone and check the next row
Else
if B2=C2 and D2=E2 and F2=G2 and H2=I2 and J2=K2 and N2=O2 and P2=Q2 delete
this entire row (all 7 conditions must be met to eliminate this row)
If any of 7 conditions fail then I need to keep this row.
Thank you.
 
L

Luke M

Here's a non-VB method:
You could create a hlper column with this formula copied down. Then do an
AutoFilter for "DELETE ME" and delete those rows.

=IF(AND(L2<>M2,B2=C2,D2=E2,F2=G2,H2=I2,J2=K2,N2=O2,P2=Q2),"DELETE ME","")
 
O

Otto Moehrbach

Something like this perhaps. HTH Otto
Sub DeleteRows()
Dim rColA As Range
Dim c As Long
Set rColA = Range("A2", Range("A" & Rows.Count).End(xlUp))
For c = rColA.Count To 1 Step -1
If rColA(c).Offset(, 11) <> rColA.Offset(, 12) Then
If rColA(c).Offset(, 1) = rColA.Offset(, 2) And _
rColA(c).Offset(, 3) = rColA.Offset(, 4) And _
rColA(c).Offset(, 5) = rColA.Offset(, 6) And _
rColA(c).Offset(, 7) = rColA.Offset(, 8) And _
rColA(c).Offset(, 9) = rColA.Offset(, 10) And _
rColA(c).Offset(, 13) = rColA.Offset(, 14) And _
rColA(c).Offset(, 15) = rColA.Offset(, 16) Then _
rColA(c).EntireRow.Delete
End If
Next c
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top