removing large numbers of empty rows

kerrysr

New Member
Joined
Mar 7, 2002
Messages
11
I have a large spreadsheet with a large number of empty rows. It would take forever to select each row and delete it.

I tried ASAP utilities but it does not remove the empty rows.

Any suggestions?

Thks
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I just tried asap utilities re: deleting empty rows and it worked for me. Here is what I used:

Select - Conditional row and column select, hide or delete, perform action in (choose your data), search options - completely empty rows, what to do when found rows/columns (radio button) choose, click start. This deleted my empty rows.
 
Upvote 0
Here is a macro :-
Code:
Sub DeleteEmptyRows()
    Dim ws As Worksheet
    Dim MyDeleteRange As Range ' macro sets range for deletion
    Dim DeletedRows As Long
    Dim MyCell As Range        ' single cell added to MyDeleteRange
    Dim LastRow As Long
    Dim Foundcell As Object
    '----------------------------------------------------------------
    Application.Calculation = xlCalculationManual
    DeletedRows = 0
    Set ws = ActiveSheet
    '- find last row
    Set Foundcell = ActiveSheet.Cells.Find(what:="*", _
        after:=Range("IV65536"), searchdirection:=xlPrevious)
    LastRow = Foundcell.Row
    '----------------------------------------------------------------
    '- check cells
    For r = 1 To LastRow
        If Application.WorksheetFunction.CountA(ws.Rows(r).EntireRow) = 0 Then
            DeletedRows = DeletedRows + 1
            Set MyCell = ws.Cells(r, "A")
            If MyDeleteRange Is Nothing Then
               '- first matching cell
               Set MyDeleteRange = MyCell
            Else
               '- add subsequent matching cells to the range
               Set MyDeleteRange = Union(MyDeleteRange, MyCell)
            End If
        End If
    Next
    '----------------------------------------------------------------
    '- delete all rows in the range
    MyDeleteRange.EntireRow.Delete
    Application.Calculation = xlCalculationAutomatic
    MsgBox ("Deleted " & DeletedRows & " rows.")
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,868
Messages
6,122,005
Members
449,059
Latest member
mtsheetz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top