macro to automatically remove blank rows

J

Jack Wood

I have an output form in a worksheet that draws selected items from
another worksheet called Master. Is there a macro that will remove any
blank rows on my output form?
 
M

Mike H

Jack

Right click your worksheet tab, view code and paste this in and run it

Sub Sonic()
Dim i As Long
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = LastRow To 1 Step -1
If WorksheetFunction.CountA(Rows(i)) = 0 Then
Rows(i).EntireRow.Delete
End If
Next i
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub

Mike
 
J

Joel

Sub deleterows()

With ActiveSheet
LastRow = .Cells.SpecialCells(xlCellTypeLastCell).Row

For RowCount = LastRow To 1 Step -1
LastCol = .Cells(RowCount, Columns.Count) _
.End(xlToLeft).Column
If LastCol = 1 Then
If .Range("A" & RowCount) = "" Then
.Rows(RowCount).delete
End If
End If
Next RowCount
End With
End Sub
 
Top