Delete Rows that Meet Certain Criteria in VBA

Associated Files Download Links

The following Subroutine will delete each row in a range where the value in Column A begins with a prescribed piece of text:

For example Delete_Rows(Sheets(“Sheet1”).Range(“A1:E23”,”Dog”) will delete all the rows in the range A1:E23 where the value in Column A begins with the word “Dog”. Note the use of Ucase means that the formulae is case INSENSITIVE i.e cells that begin with any of DOG, Dog, DoG or dog will all be deleted.

This:
delete rows
Will become:
delete rows meeting certain criteria

alt text

You may also like some of this related content...

Delete Blank Rows The obvious way to remove blank rows from a data set is
If you ever need to count the number of rows that were selected, use Selection.Rows.Count
Select Every 5th Row Imagine that we have 20,000 rows of data in an Excel
Here is example code to determine the Start and End Column of a Merged Cell.
After you manipulate a worksheet with VBA it may be necessary to Autofit your columns
Ads