I have a problem with deleting balnk rows using VBA. I have the following code that works on one page of my WB. I have used formula's on sheet 2 to extract only the information I want to keep. I then want to delete all blank rows but the VBA doesn't work.
I have tried copying the sheet and pasting values only but for some reason the CountA function is counting empty cells and thus the macro is not working. So if I do Counta on an "empty" row it retuns 47!! Help...
VBA code:
Sub del()
With Application
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
End With
End Sub
I have tried copying the sheet and pasting values only but for some reason the CountA function is counting empty cells and thus the macro is not working. So if I do Counta on an "empty" row it retuns 47!! Help...
VBA code:
Sub del()
With Application
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
End With
End Sub