One of the most common tasks in Excel is deleting blank lines. Whatever type of data you may have in Excel, there are many occasions where you will also have a bunch of blank lines throughout the file.

If you have thousands of rows, manually deleting blank lines is a major pain and virtually impossible. The most common way to delete blank lines in Excel, at least as mentioned online, is to use some sort of Excel macro.

However, if you’re not familiar with macros, this method can be difficult to implement. Also, if it doesn’t work properly, you may have no idea how to change the macro for your particular Excel file.

Luckily, there is a simple and very effective way to delete blank lines without any macros. It basically involves sorting. Here’s how you do it.

Let’s say we have the following set of data in Excel and we want to get rid of the blank lines:

delete blank lines excel

The first thing we’ll do is insert a column and number it consecutively. You might ask why we would want to do this? Well, if the order of the rows matters, when we sort Column A to get rid of the blank lines, there will be no way to get the rows back in the order they were before sorting.

Here’s what the sheet should look like before we sort the animal name column:

remove blank lines excel

Now select both columns and click on the Data ribbon in Excel 2007. Then click on the Sort button.

excel delete blank lines

For Sort By, choose Column B and then click OK. Note that you want to sort the column that have the blank values in it. If more than one column has blank values, just pick one.

delete blank lines

Now your data should look like this below. As you can see, it’s easy to delete the blank rows because they are all at the bottom:

remove blank lines

Once you delete the rows, now you can probably see why we added the column with the numbers? Before sorting, the order was “Cat, Dog, Pig, etc..” and now it’s “Bear, Cat, Cow, etc…”. So just sort again by column A to get the original order back.

excel delete blank rows

Pretty easy right? What I like about this method is that it’s also really easy to delete rows that only have one column with blank values rather than the entire row being blank. Enjoy!