VBA: Remove Blank Rows
The obvious way to remove blank rows from a data set is to simply sort the data. This moves the blank rows to the bottom of the data and “removes” them. But what if you want the blank rows removed, however you don’t want the data sorted? VBA.
The following macro will remove blank rows without any sorting (turn off screen updating to go faster).
Sub DeleteBlankRows() Dim x As Long With ActiveSheet For x = .Cells.SpecialCells(xlCellTypeLastCell).Row _ To 1 Step -1 If WorksheetFunction.CountA(.Rows(x)) = 0 Then ActiveSheet.Rows(x).Delete End If Next End With End Sub