how do i find and delete all empty rows in an excel worksheet

G

Guest

how do i find and delete all empty rows in an excel worksheet that was
created by exporting a double spaced crystal report ?
 
G

Gord Dibben

If for sure you have a blank row between each data row.

Select a column.

F5>Special>Blanks>OK

Edit>Delete>Entire Row


Gord Dibben MS Excel MVP
 
G

Guest

Yes thanks but this seems limited to the selected column. The worksheet has
rows that may have blank cells in some columns but not all. What I need to
delete are all empty rows only.
 
G

Gord Dibben

Sub DeleteEmptyRows()
''only if entire row is blank
lastrow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False
For r = lastrow To 1 Step -1
If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r
End Sub

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and Insert>Module. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run the macro by going to Tool>Macro>Macros.

You can also assign this macro to a button or a shortcut key combo.


Gord


Yes thanks but this seems limited to the selected column. The worksheet has
rows that may have blank cells in some columns but not all. What I need to
delete are all empty rows only.

Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top