Excel Developer Tip


Return to The Spreadsheet Page

Excel page

Tip archives

Deleting All Empty Rows

The subroutine below is a fast and efficient way to delete all empty rows in the active worksheet

Sub DeleteEmptyRows()
    LastRow = ActiveSheet.UsedRange.Row - 1 + _
        ActiveSheet.UsedRange.Rows.Count
    Application.ScreenUpdating = False
    For r = LastRow To 1 Step -1
        If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
    Next r
End Sub