How to Delete Entire Rows if Blank Cell Exists in Excel

Sometimes we need to delete the entire row which contains blank cell from a table. Though we can delete them by right click on row index and just ‘Delete’ them manually, if they are not adjacent or the table is very long, to delete rows manually is very troublesome. As there are a lot of powerful features built in Excel, actually we can delete rows via these features. In this free tutorial, we will introduce you to delete entire rows contain blank cells from a spreadsheet by two ways via Go To Special function and VBA Macro.

Precondition:

See screenshot below. There are two blank cells exist in this table. As they are invalid, so we need to remove the two rows.

How to Delete Entire Rows if Blank Cell Exists in Excel1

Method 1: Delete Entire Rows by Go To Special function


Step 1: Select the table. Then click Home in the ribbon, click Find & Select icon under Editing group, and select Go To Special option. See screenshot below.

How to Delete Entire Rows if Blank Cell Exists in Excel2

In this step, you can also press F5 to load Go To dialog, and click Special button to load Go To Special dialog as well.

How to Delete Entire Rows if Blank Cell Exists in Excel3

Step 2: On Go To Special dialog, check on Blank option. Then click OK.

How to Delete Entire Rows if Blank Cell Exists in Excel4

Step 3: After above operating, blank cell rows are auto selected.

How to Delete Entire Rows if Blank Cell Exists in Excel5

Step 4: Right click on one of the select rows, click Delete.

How to Delete Entire Rows if Blank Cell Exists in Excel6

Step 5: On Delete dialog, check on Entire row. Then click OK.

How to Delete Entire Rows if Blank Cell Exists in Excel7

Step 6: Check the updated table. Verify that rows contain blank cells are deleted.

How to Delete Entire Rows if Blank Cell Exists in Excel8

Method 2: Delete Entire Rows by VBA Macro


Step 1: On current visible worksheet, right click on sheet name tab to load Sheet management menu. Select View Code, Microsoft Visual Basic for Applications window pops up.

How to Delete Entire Rows if Blank Cell Exists in Excel9

Or you can enter Microsoft Visual Basic for Applications window via Developer->Visual Basic. You can also press Alt + F11 keys simultaneously to open it.

How to Delete Entire Rows if Blank Cell Exists in Excel10

Step 2: In Microsoft Visual Basic for Applications window, click Insert->Module, enter below code in Module1:

Sub DeleteEntireRow()

Dim SelectRng As Range

On Error Resume Next

xTitleId = "Delete Entire Row"

Set SelectRng = Application.Selection

Set SelectRng = Application.InputBox("Please select your range", xTitleId, SelectRng.Address, Type:=8)

Set SelectRng = SelectRng.SpecialCells(xlCellTypeBlanks)

If Err = 0 Then

SelectRng.EntireRow.Delete

End If

End Sub

Step 3: Save code and quit Microsoft Visual Basic for Applications.

Step 4: Click Developer->Macros to run Macro. Select ‘DeleteEntireRow’ and click Run.

How to Delete Entire Rows if Blank Cell Exists in Excel11

Step 5: Delete Entire Row dialog pops up. Select range $A$2:$B$16. Click OK. In this step you can select the range you want to do delete rows with blank cells.

How to Delete Entire Rows if Blank Cell Exists in Excel12

Step 6: Click OK and check the result. Verify that we get the same result as method1.

How to Delete Entire Rows if Blank Cell Exists in Excel8

Related Posts

Find and Replace Multiple Values

This post will guide you how to find and replace multiple values at once with VBA macro or using formula  in Excel. How do I make multiple find and replace in Excel. Suppose that you have a few cells containing ...

VBA Macro For VLOOKUP From Another Sheet

In the previous post, you should know that how to fix or remove the #N/A error when using VLOOKUP formula to lookup value from another sheet. And this post will show you how to use VBA code to vlookup data ...

How To Insert Comments in Protected Worksheet in Excel

This post will show you how to allow comments in a protected worksheet in Excel. You can easily to insert comments into cells in a normal worksheet in Excel, but if want to insert a comment in a worksheet that ...

How To Convert Text to Upper Cases(Using VBA) in Excel

This post will show you how to switch from lower case to upper case in Excel. and I am going to show you two different ways of converting text to upper cases using formula or VBA macro in Excel 2013,Excel ...

How To Hide Every Other Row in Excel (Using VBA)

This post will show you how to hide alternate rows or columns in Excel or how to hide every third, fourth, fifth row or column in Excel. If you want to hide every other row in your current worksheet, how ...

Sidebar