Hi all, I have found the below macro to remove blank rows in a sheet. I run it, however it does not remove the blank rows (but tells me that it has).
I think I need to set the range. I have added a Range called 'Blank_Cells' but I don't know how I add this into the code, can anybody please help?
Thanks.
Sub DeleteBlankRows()
Dim Rw As Range
If WorksheetFunction.CountA(Selection) = 0 Then
MsgBox "No blank rows found", vbOKOnly
Exit Sub
End If
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
Selection.SpecialCells(xlCellTypeBlanks).Select
For Each Rw In Selection.Rows
If WorksheetFunction.CountA(Selection.EntireRow) = 0 Then
Selection.EntireRow.Delete
End If
Next Rw
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
MsgBox "Blank Rows Removed"
End Sub
I think I need to set the range. I have added a Range called 'Blank_Cells' but I don't know how I add this into the code, can anybody please help?
Thanks.
Sub DeleteBlankRows()
Dim Rw As Range
If WorksheetFunction.CountA(Selection) = 0 Then
MsgBox "No blank rows found", vbOKOnly
Exit Sub
End If
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
Selection.SpecialCells(xlCellTypeBlanks).Select
For Each Rw In Selection.Rows
If WorksheetFunction.CountA(Selection.EntireRow) = 0 Then
Selection.EntireRow.Delete
End If
Next Rw
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
MsgBox "Blank Rows Removed"
End Sub