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
VBA Macro For VLOOKUP From Another Sheet
vba macro for vlookup from another sheet1

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
insert commetns in protected workshee3

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
convert text to upper cases1

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)
hide every other row1

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 ...

How to Disable the Save As Prompt in Excel
disable save as prompt1

This post will show you how to use a VBA Macro to save an Excel file and overwrite any existing file without a prompt so that you are going to get the little window that says file already exists do ...

How to Count Cells that Contain even or odd numbers in Excel
count cells that contain even numbers5

This post will guide you how to count the number of cells that contain odd or even numbers within a range of cells using a formula in Excel 2013/2016.How do I count cells that contain odd numbers through the use ...

How to Count Cells that Contain negative Numbers in Excel

This post will guide you how to count the number of cells that contain negative numbers within a range of cells using a formula in Excel 2013/2016.You can count the number of negative numbers in your data using easy functions ...

How to Count Cells Are Not Blank or Empty in Excel
count non blank nonempty cells5

This post will guide you how to count cells that are not blank or empty in a given range cells using a formula in Excel 2013/2016.How do I count the number of cells that are not blank in a particular ...

How to Count Cells Less Than a Specific Value in Excel
count cells lessr than5

This post will guide you how to count the number of cells less than a particular numeric value in a given range cells using a formula in Excel 2013/2016. How do I count cells that are less than a specific ...

How to Count Cells Greater Than a Specific Value in Excel
count cells greater than 5

This post will guide you how to count the number of cells greater than a particular numeric value in a given range cells using a formula in Excel 2013/2016. How do I count cells that are greater than a specific ...

Sidebar