Delete Blank Rows in Excel 2010

Blank rows in a Excel spreadsheet can make working with a list of data more difficult. Basic processes such as sorting, filtering and going to the end of your list will not always work as expected.

Fortunately there are many ways of identifying and removing blank rows in Excel 2010. Let's have a look at some of them.

Using Go To Special

One way of removing blank rows in a list is to select them first using the select blanks feature of Go To Special. The rows can then be deleted.

  1. Select the column where you want to look for blanks. This should ideally be an ID or other reference field that you know should never be blank.
  2. Click the Home tab on the Ribbon.
  3. Click the Find & Select button and select Go To Special.
  4. Select Blanks and click OK.
  5. The blank cells of the column are selected. Click the Delete list arrow and select Delete Sheet Rows.

Using the Filter

Blank rows can also be deleted by using the Filter feature in Excel. Filter the list to display the blanks and then delete them.

  1. Select the whole list of data.
  2. Click the Filter button on the Data tab of the Ribbon. The filter arrows appear across the header row.
  3. Click the filter arrow for the column you want to use to search for blanks
  4. Uncheck the Select All box and check the Blanks option.
  5. Click Ok. The filter runs and displays only the blank rows from the list.
  6. Select the blank rows. These can be identified by the blue row numbering.
  7. Click the Home tab of the Ribbon.
  8. Click the Delete list arrow and select Delete Sheet Rows.

Macro to Delete the Blank Rows

The quickest and most efficient way of deleting blank rows from a spreadsheet is to create a macro. Deleting blank rows will be as easy as clicking a button.

This macro will check that the row is blank as opposed to a single cell like the previous examples.

  1. Open the Visual Basic Editor by pressing Alt + F11
  2. Insert a module by clicking the Insert menu and selecting Module
  3. Enter or copy and paste the code below into the window

In the code below comments are used to explain each section of the code.

Sub RemoveRows()

Dim lastrow As Long
Dim ISEmpty As Long

‘Count how many records in the list. This is done so that the Do loop has a finish point.
lastrow = Application.CountA(Range(“A:A”))

‘Start at the top of the list
Range(“A1″).Select

‘Loop until the end of the list
Do While ActiveCell.Row < lastrow

‘Assign number of non empty cells in the row
ISEmpty = Application.CountA(ActiveCell.EntireRow)

‘If ISEmpty = 0 then delete the row, if not move down a cell into the next row
If ISEmpty = 0 Then
ActiveCell.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If

Loop

End Sub

More by this Author


Comments

No comments yet.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working