How To Delete Rows In VBA Based On Criteria

In this post I am going to show you all how to delete rows with the length of the value in column “A” less than 2.

The first way is the not VBA way, and it will be first to determine the length of the cell value using the “len” function:

After, you get all the resulting numbers of length equal to or less than 2,

…now you can just highlight the rows and press the “delete” key on your keyboard.

Way number 2 is to use VBA.

We will loop all the cells in column “A”, and if the length of the value is equal or less than 2, we’ll delete the row.

Here’s the code:

Way #2 seems quicker to me, what do you think?

Watch how it’s done:

****************************************************

Please remember to subscribe to my youtube channel

Been helped? Get these!

Facebooktwittergoogle_plusredditpinterestlinkedinmail