Yasser, Derek,
here it is just the first VBA rule to keep in mind :
TEBV (1) …
Better than using a loop and working cell by cell or row by row
(the more rows, the slower) is to use Excel basics !
• In a helper column, F as here it's just column A to E,
just apply an easy formula (at very beginner level !)
testing the cells, example in F2 :
=AND(A2>2016,B2>15)
Result displays FALSE for a row to keep and TRUE if to be deleted …
• Sort range from column A to F on column F in ascending way :
the rows to delete (TRUE) are now at the end of range …
• Use
Find or MATCH Excel function on column F to get the first TRUE
so the first row to delete.
• From this first row to delete until the last row, use
Range.Clear method
as it is faster than
Delete and 'cause all rows to delete are yet at the end,
no needing to move up any row under ! Clear too column F …
(1) Think
Excel
Before
VBA ! That's it !
Whatever you live in Egypt or in Bulgaria …
Edit : after a private message from Bulgaria (yes Chandoo is World Wide !)
I must precise : this post is a reminder to use Excel basics
within a VBA code as it can be faster than a classic VBA loop …