Discussion Locked

Eliminate many blank lines in Excel

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have a file some 1500 lines long. Every 5 to 10 lines, there is a blank row. How can I remove all of the blank rows with one command?

1 reply

by Member 25480311

I found this macro for deleting multiple blank rows at www.mrexcel.com. It works in both Excel 97 and 2000.

Select a range or multiple ranges and run the following macro:

Sub DeleteBlankRows()

Dim num As Integer, I As Integer
Dim area As Object

For Each area In Selection.Areas
area.Select
num = Selection.Rows.Count
If num = 65536 Then
num = Selection.SpecialCells(xlLastCell).Row
End If

'loop through each row and delete if all cells are empty.
For I = 1 To num
If Application.CountA(ActiveCell.EntireRow) = 0 Then
ActiveCell.EntireRow.Delete
Else
If I <> num Then ActiveCell.Offset(1, 0).Select
End If
Next I
Next 'loop back and do next area

End Sub

This discussion is closed to new replies.