Justin
asked on
Do Loop to delete empty rows
Hi Guys, I have a downloaded report in Excel which is 32 pages long and full of page breaks. I would like a Macro Do Loop which deletes all the blank lines. Can someone help?
Example3.xlsx
Example3.xlsx
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi RGonzo, your Macro looks good, but I want to take out the headings of each page as they are just repeating. Can you adapt the Macro to delete the rows where column 11 is blank?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
simply add this line either in my code above like this or in Rgonzo's code
Columns("K").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Sub DeleteRows()
ActiveSheet.UsedRange.Select
'Deletes the entire row within the selection if the ENTIRE row contains no data.
Dim i As Long
'Turn off calculation and screenupdating to speed up the macro.
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
'Work backwards because we are deleting rows.
For i = Selection.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
Selection.Rows(i).EntireRow.Delete
End If
Next i
Columns("K").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
ASKER
It works great
Highlight the whole area and Delete Rows. It will only delete those that are visible.
Thanks
Rob H