Excel Remove Blank Rows
To remove blank rows in Excel, Open the worksheet & follow these menu options.
- Select data range that has empty Rows.
- Click on option Home -> Find & Select -> choose “Special”.
- Select ‘Blanks’ & click OK in the Pop-up menu.
- Empty Cells in the selected Range will be highlighted.
- Click Home menu -> Delete -> Delete Sheet Rows.
Now, notice that this option will delete all empty rows in Excel & the user can happily move on to processing only the valid data.
Microsoft keep on adding new features in Excel, one of the most widely used Office Applications. In Excel, we might be having lot of Empty rows, cells, columns while processing data. It creates problems for us in getting desired result. Lets see how to identify & remove empty rows in between huge data rows.
Also Read: Remove Duplicate Values From Excel Sheet
Excel Remove Empty Rows with Built in Option
In the introduction, we just learned how to use the built-in option available in Excel to remove empty rows in Excel, What is the limitation in using the Built in option? and How to overcome the limitation using a VBA to delete blank rows?.
Well, if you are in hurry you can directly download sample excel document or use the VBA at end of this topic to remove empty rows.
Limitation with Built in Delete Empty Rows
Consider that data range or table selected does not have empty rows. Instead, only some of the columns or cells are empty.
In this case, if you choose the built-in option, it will delete row completely even if any single cell has no data. This will result in data loss.
- Row/Column ColumnA ColumnB ColumnC
- Row1 DataA1 DataB1 DataC1
- Row2 DataA2 <Empty> DataC2
- Row3 DataA3 DataB3 DataC3
In this example, Row2 has an empty cell. If you choose the steps explained in Build in Option, then it will delete Row2 also. So, you data in Row2 will be lost or it will delete row2 column 2. and DataB3 will be moved up.
This will result in mismatched data in the table. So, it is always better to go with the Excel VBA code to remove blank rows.
Excel VBA Delete Empty Rows
This Excel VBA code will delete all empty rows in the sheet1. Modify the code to include the sheet name if you want to perform this operation on a different worksheet.
Note: Below Excel Macro is limited to 256 columns. If your Excel version has more number of columns, then change the data type of variables from Integer to Double and increase the column limits from 256.
123456789101112131415161718192021222324252627282930313233343536Option Explicit'Code from Officetricks.com - How to Delete Blank Rows in Excel using VBA?Sub Excel_VBA_Delete_Blank_Rows()Dim iRow As Double, iCol As DoubleiRow = 1iCol = 1While True'Check whether Cell 1 is Blank for that a rowActiveSheet.Cells(iRow, iCol).SelectIf VBA.Trim(ActiveSheet.Cells(iRow, iCol)) = "" ThenWhile True'If Cell 1 is Blank then verify all the columns in that rowIf VBA.Trim(ActiveSheet.Cells(iRow, iCol)) <> "" ThenGoTo Skip_To_Next_Row:End IfiCol = iCol + 1If iCol > 256 Then GoTo Del_Row:WendDel_Row:'If first cell is Empty, then execute VBA Code to Delete a Row in ExcelActiveSheet.Rows(iRow).Delete Shift:=xlUpiRow = iRow - 1End IfSkip_To_Next_Row:iRow = iRow + 1If ActiveSheet.UsedRange.Rows.Count < 2 Then GoTo End_Process:If iRow > ActiveSheet.UsedRange.Rows.Count Then GoTo End_Process:iCol = 1WendEnd_Process:MsgBox "Excel Delete Blank Rows Completed - Thanks for visiting Officetricks.com"End Sub
The above Excel VBA code, scans picks each column in each row & deletes that row only if complete rows has no data. If you are facing any issues while deleting empty rows using this VBA code, then leave us a comment.
Remove Empty Rows Add-in for Excel
If you have lot of Excel files in which the empty rows has to be removed, then use our free Add-in.
- Download the below add-in file to this location: C:\Users\<ActiveUserName>\AppData\Roaming\Microsoft\AddIns
- Open the Excel workbook that has lot of blank rows.
- Click on Office Ribbon on left hand menu top.
- Select “Excel Options” -> “Add-Ins”.
- Choose “Excel Add-Ins” in Manage field and click “Go” button.
- Click on check box for ‘Delete Blank Rows” & click ok.
Now, go to your Excel workbook and press Ctrl + d. Then this add-in function will be invoked and all blank rows will be deleted.
Download Excel VBA Delete Empty Rows Add-In Downloaded 77 Times
In case if you want more customized process to be followed, then use the code in this page.
Sample Excel VBA to Delete Empty rows Downloaded 307 Times
More Tips: Remove Junk Data From Text File
There is another interesting Plugins from AbleBits website for such quick Excel operations.
Previous Post: 7 Best Free Android Games from Play Store
Next Post: Create an Index with Link to all Sheets in a Excel Workbook
Tips: Excel VBA Delete Empty Rows – excel Remove Blank Rows