ExcelTip.com
ExcelTip.com
Account Icon Account Icon Account Icon
Google Exceltip.com
JOIN OUR NEWSLETTER
  and receive for joining:
Free eBook Learn More!
Free Excel ADD-IN
Free Weekly Excel Tip
4 e-books in cd-rom
F1 Formulas & Functions
F1 Formulas & Functions
F1 EXCEL
F1 eBook (Spanish)
F1 EXCEL
Financial Statements.xls
 

» Deleting Empty Rows
To delete empty rows between data:

1. Select all columns containing data.
2. Click the Sort icon (either Ascending or Descending).



Screenshot // Deleting Empty Rows

Deleting Empty RowsDeleting Empty Rows
Rate this tip
12 34 5
  RATING: 2.68
  VIEWS: 101331

READER COMMENTS (view all comments)


alternative
Bhagyesh wrote on December 31, 1969 19:00 EST
we can use auto filter and delete the rows if we dont want to sort
F5 key
Nimrod wrote on December 31, 1969 19:00 EST
Selecting certain types of cells is wht the "Goto" F5 key is for. Just Slect the columns in question , press F5 and then select "blanks" in the Goto window. Now only the blank cells are selected. Once Selected you can do anything you want with them ... eg right click and delete , or bold , or what ever.

wrote on December 31, 1969 19:00 EST
This not work when cell is containg untype characters
like NULL or formula ="" or something that similar but it is not really enpty cell. Very oftet in occure when copy from NULL from access by CTR + C and CTR + V. Export table feature work correctly and instead of NULL return really empty cell.
Macro to delete rows
Gary L Brown wrote on December 31, 1969 19:00 EST
'/============================/
' Sub Purpose: Delect all blank ROWS within the active cell's
' Used Range
'
Public Sub DeleteBlankRows()
Dim dbMaxRow As Double, dbMinRow As Double, i As Double
Dim dbMaxCol As Double
Dim rng As Range

On Error Resume Next

'only look in used area of the worksheet where active cell is
Set rng = Selection.Parent.UsedRange

'calculate area to be searched for blank rows
dbMaxRow = rng.Rows.Count '# of rows in used area
dbMinRow = rng.Cells(1, 1).Row '1st row in used area
dbMaxCol = rng.EntireColumn.Count '# of columns in used area

For i = dbMaxRow To dbMinRow Step -1
If IsError(rng.Cells(1, 1).Offset(i - 1, 0).EntireRow. _
SpecialCells(xlCellTypeBlanks).Count) Then
Else
If rng.Cells(1, 1).Offset(i - 1, 0).EntireRow. _
SpecialCells(xlCellTypeBlanks).Count = dbMaxCol Then
rng.Cells(1, 1).Offset(i - 1, 0).EntireRow.Delete
End If
End If
Next i

Set rng = Nothing

End Sub
'/============================/
'
Pitfall
Balkee wrote on December 31, 1969 19:00 EST
Depending on the contents of the first column in the range, the sorting will cause the order of rows to be different from the original order. After you delete the blank rows, it may be a bigger hassle getting back to the original order. Use filter as Bhagyesh suggested.
I found that
Rhobbynho wrote on December 31, 1969 19:00 EST
'Matt Neuburg, PhD http://www.tidbits.com/matt Aug , 1998

Sub DelEmpty()
Selection.SpecialCells(xlCellTypeBlanks).Delete (xlShiftUp)
End Sub
Agreed
Ade wrote on December 31, 1969 19:00 EST
Really no need to use sort instead of go to. A macro is a good idea if you want to include it in the code you write.
Easier than that
c7borg wrote on December 31, 1969 19:00 EST
just press f5 select special and check the "blanks" radio button then simply select edit>delete

job done
Alternative to deleting blank rows
Roger Morehouse wrote on December 31, 1969 19:00 EST
ALthough I agree that AutoFilter works great for some worksheets, a large worksheet will bog down using this method. If you need to maintain the order of the rows, insert a new column, fill with numbers, sort by desired column, delete blank rows, sort by number column, delete number column.
Alternate to Sorting, then deleting
Roger Morehouse wrote on December 31, 1969 19:00 EST
For large worksheets, another method is to insert a column, then fill with numbers. Sort by the desired column, delete the rows, resort by the number column. But I agree, Filter is good for small worksheets.
AWESOME
dude wrote on December 31, 1969 19:00 EST
you are so good with the Macro - i took 45 mins to do this manually in the morning - and your macro did it in 3 seconds flat -- THANK YOU FOR THIS <SALUT!>



REGISTERED USERS - Click here to post comments


GUESTS (Click here to register)
Name
Comment Title
Comments

Retire Young, Retire Rich

Real Estate Finance and Investments (Real Estate Finance and Investments, 11th Ed)

The McGraw-Hill 36-Hour Course in Finance for Nonfinancial Managers

Adventure Capitalist: The Ultimate Road Trip

Marketing Plans

The Essential 55: An Award-Winning Educator's Rules for Discovering the Successful Student in Every Child

RELATED MICROSOFT EXCEL TIPS


Convert PDF Files to Excel






Excel VBA books
Accounting books
Business Plans
MS Office books
Taxes books

VIEW ALL BOOKS


  Advertise With Us                               

Tips

Add-In in VBA | Applications - Word, Outlook in VBA | Array Formulas | Cells, Ranges, Rows, and Columns in VBA | Counting | Custom Functions | Custom Functions in VBA | Database Formulas | Database in VBA | Date & Time Formulas | Date & Time in VBA | Events in VBA | Excel 2003 | Excel Chart | Excel Consolidating | Excel Counting | Excel Custom Functions using VBA | Excel Customizing | Excel Data | Excel Dates | Excel Editing | Excel Files | Excel Filter | Excel Format | Excel Formula | Excel General | Excel Grouping and Outlining | Excel Importing Text Files | Excel Information | Excel Keyboard Shortcuts | Excel Loan Formulas | Excel Macros - VBA | Excel Pivot Tables | Excel Printing | Excel Range Name | Excel Security - Protection | Excel Sorting | Excel Style | Excel Subtotals | Excel Summing | Excel Text | Excel Time | Excel Tools | Excel Worksheet, Workbook | Files, Workbook, and Worksheets in VBA | Financial Formulas | Formating in VBA | General Topics in VBA | Import and Export in VBA | Information Formulas | Keyboard & Other Shortcuts in VBA | Keyboard Formula Shortcuts | Links between Worksheet and Workbooks | Links in VBA | Logical Formulas | Lookup Formulas | Mail - Send and Receive in VBA | Menus, Toolbars, Status bar in VBA | Modules, Class Modules in VBA | Other Q&A Formulas | Printing in VBA | Protecting in VBA | Summing | Text Formulas | User Forms, Input boxes in VBA | Using Loops | Working with Formulas |

Tips by Version

Microsoft Excel 97 | Microsoft Excel 2000 | Microsoft Excel 2002 | All Microsoft Excel Versions | New in Excel 2002 | New in Excel 2003 - Office 11

Website

Home | Tip of Hour | Recommended Tips | Most Viewed Tips | Tips by Version | Submit a Tip | My Tips
Microsoft Excel Tutorials | Excel Links | Write for Us | About Us | Search Results | Tip Archives | Excel Forum | Excel Forum Archives

Excel Book

Excel 97 Book | Excel 2000 Book | Excel 2002 Book | Excel XP Book | Book Store

Terms and Conditions of use
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

Copyright © 2003 ExcelTip.com
Microsoft, Microsoft Excel is a U.S. registered trademark of Microsoft Corporation
Site Developed By: Varien