Question : Deleting blank rows

I need to find all the empty rows and delete them from my worksheet

NextRow = Application.WorksheetFunction.CountA(Range("A:A"))

Answer : Deleting blank rows

Deepandp's code will delete all rows where the first cell is blank, not necessarily the whole row. This update (from http://www.automateexcel.com/2004/12/20/excel_vba_remove_blank_rows/)  will only remove fully blank rows.

Thomas
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
Sub DeleteBlankRows()
Dim x As Long
application.screenupdating=false
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
application.screenupdating=true
End Sub
Random Solutions  
 
programming4us programming4us