You can do it without VBA
Select the entire table
Data > Filter > Autofilter and choose " Non blanks" in the dropdown lists.
You can then copy paste the result where you like.
You can also " Record Macro" while doing this, it would give you the code
Select the range in question and run the following:-
Public Sub DeleteReallyBlankRows()
'Chip Pearson
'Will delete all rows that are entirely blank
Dim r As Long
Dim c As Range
Dim n As Long
Dim rng As Range
On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If Selection.Rows.Count > 1 Then
Set rng = Selection
Else
Set rng = ActiveSheet.UsedRange.Rows
End If
n = 0
For r = rng.Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(rng.Rows(r).EntireRow) = 0 Then
rng.Rows(r).EntireRow.Delete
n = n + 1
End If
Next r
EndMacro:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Just to add my two cents worth here are two solutions you could use:
Another non-VBA solution:
1. Select Column A:A
2. Press Ctrl+G
3. select Special...
4. Select Blanks
5. Right Click one of the selected blanks
6. Select Delete...
7. Select Entire Row
8. Press OK
You can record the above into a macro too. ;-)
Another VBA solution:
Sub DeleteBlanks()
Application.ScreenUpdating = False
Dim LastRow As Long
LastRow = Range("A65536".End(xlUp).Row
Range("A1".Select
Do Until ActiveCell.Row = LastRow
If Application.WorksheetFunction.CountA(Rows(ActiveCell.Row)) = 0 Then
ActiveCell.EntireRow.Delete
End If
ActiveCell.Offset(1, 0).Select
Loop
Range("A1".Select
Application.ScreenUpdating = True
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.