delete all blank rows in a spreadsheet
Sub RemoveEmptyRows()
Dim xr As Long, xc As Integer, dRow As Boolean
Dim CalcType As Long
With Application
.ScreenUpdating = False
CalcType = .Calculation
.Calculation = xlCalculationManual
End With
For xr = Val(StrReverse(UsedRange.Address)) To 1 Step -1
dRow = True
For xc = 1 To 255
If Len(Trim(Cells(xr, xc))) 0 Then
dRow = False
Exit For
End If
Next xc
If dRow Then Rows(xr).Delete shift:=xlUp
Next xr
With Application
.ScreenUpdating = True
.Calculation = CalcType
End With
End Sub
--
Cheers
Nigel
"Richard" wrote in message
...
How do I delete entire rows in a spreadsheet with a VBA macro?
I can't use autofilter (or similar techniques) as not all of the columns
have data in every non blank row i.e. if I sorted by column A, there may
be a
row with a blank cell in column A, but another column (say AX) that may be
out of view could have data in it.
|