Note: The other languages of the website are Google-translated. Back to English

How to delete entire row if cell contains zero in Excel?

Sometimes, you want to delete the entire row if the cell contains zero in Excel, and you can delete them one by one if there are a few of them. But how about hundreds of rows containing zero needed to be removed? You can choose one of the tricky ways below to solve it.

Delete row if cell contains zero with Filter function in Excel
Delete row if cell contains zero with VBA in Excel
Delete row if cell contains zero with Kutools for Excel


Delete row if cell contains zero with Filter function in Excel

You can use the Filter function to filter out all rows based on the zero values in a certain column, and then delete all visible rows later. Please do as follows.

1. Select the column cells which contain the zero values you want to delete the entire rows based on, then click Data > Filter. See screenshot:

2. Then a drop-down arrow is displaying in the first cell of the selected column, click the arrow, and then select Number Filters > Equals from the drop-down list.

doc delete if zero 1

3. In the Custom AutoFilter dialog box, enter number 0 into the textbox as below screenshot shown, and then click the OK button.

doc delete if zero 1

4. Then all zero value cells in this certain column are filtered out. Please select all visible cells in the filter range and right click on them, select Delete Rows from the right-clicking menu. And in the popping up prompt box, click the OK button. See screenshot:

doc delete if zero 1

5. Now all visible rows are deleted. You can click Data > Filter again to show all data without zero value cells. See screenshot:

doc delete if zero 1


Easily delete all rows if zero values exist in a certain range in Excel:

Kutools for Excel's Select Specific Cells utility helps you to easily select entire rows if zero values exist in a certain range, and then you can quickly delete all selected rows manually without any mistakes.
Download and try it now! ( 30-day free trail)


Delete row if cell contains zero with VBA in Excel

This section will show you the VBA method to delete all rows if zero values exist in a certain column in Excel.

1. Press Alt + F11 keys simultaneously to display the Microsoft Visual Basic for Applications window.

2. In the Microsoft Visual Basic for Applications window, click Insert > Module, then copy and paste the following VBA code into the module window.

VBA: Delete entire rows if zero value exist in certain column range in a worksheet

Sub DeleteZeroRow()
'Updateby20140616
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Application.ScreenUpdating = False
Do
    Set Rng = WorkRng.Find("0", LookIn:=xlValues)
    If Not Rng Is Nothing Then
        Rng.EntireRow.Delete
    End If
Loop While Not Rng Is Nothing
Application.ScreenUpdating = True
End Sub

3. Press the F5 key to run the code, in the popping up KutoolsforExcel dialog box, select the column range you want to delete entire rows based on the zero values inside, then click the OK button. See screenshot:

doc delete if zero 1

Then all rows based on the zero values in specified column range are deleted immediately.

doc delete if zero 1


Delete row if cell contains zero with Kutools for Excel

For many Excel users, using VBA code is dangerous to remove data in Excel. If you don't exactly trust the VBA code, here we recommend you to try the Select Specific Cells utility of Kutools for Excel.

Before applying Kutools for Excel, please download and install it firstly.

1. Select the column range you will remove entire rows based on the zero values inside, and then click Kutools > Select > Select Specific Cells. See screenshot:

2. In the Select Specific Cells dialog, you need to:

(1) Select the Entire row option in the Selection type section.

(2) Select Equals in the first Specific type drop-down list, then enter number 0 into the text box.

(3) Click the OK button.

3. A dialog box pops up to tell you how many rows have been selected, click the OK button. Now all rows with the zero values exist in the specified column range are selected. Please right click to any selected row, then click Delete in the right-clicking menu. See screenshot:

doc delete if zero 1

Now all rows with the zero values exist in the specified column are deleted immediately. See screenshot:

doc delete if zero 1

  If you want to have a free trial ( 30-day) of this utility, please click to download it, and then go to apply the operation according above steps.


Delete row if cell contains zero with Kutools for Excel


Relative Articles:


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Comments (14)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
This was a life saver!!
This comment was minimized by the moderator on the site
Your VB code doesn't work. It deletes all rows with a Zero in the 10s position. I hope no one actually uses this as they will delete data...
This comment was minimized by the moderator on the site
I modified the above code to work for me. I wanted to delete every row that had "Delete" in row C. Sub Delete_DeleteRows() Set WorkRng = Range("C2:C12000") Application.ScreenUpdating = False Do Set Rng = WorkRng.Find("Delete", LookIn:=xlValues) If Not Rng Is Nothing Then Rng.EntireRow.Delete End If Loop While Not Rng Is Nothing Application.ScreenUpdating = True End Sub
This comment was minimized by the moderator on the site
I modified the below code to work for me. This deleted every row in column C that had "Delete" in the cell of column C. Sub Delete_DeleteRows() Set WorkRng = Range("C2:C12000") Application.ScreenUpdating = False Do Set Rng = WorkRng.Find("Delete", LookIn:=xlValues) If Not Rng Is Nothing Then Rng.EntireRow.Delete End If Loop While Not Rng Is Nothing Application.ScreenUpdating = True End Sub
This comment was minimized by the moderator on the site
thanks for the response, worked for me
This comment was minimized by the moderator on the site
Hi,
its worked for me, thanks a lot.
if I have multiple sheets? how i can run the script 1 time for all the sheets?
This comment was minimized by the moderator on the site
modified for my purpose--thank you for your help: Sub DeleteZeroRow() Dim Rng As Range Dim WorkRng As Range On Error Resume Next xTitleId = "" Application.Calculation = xlManual MsgBox "Set the range you want to remove the unused 0 quantity rows from" Set WorkRng = Application.InputBox("Range", xTitleId, "FG93:FG500", Type:=8) Application.ScreenUpdating = False Sheets("ENTRY").Select Do Set Rng = WorkRng.Find("0", LookIn:=xlValues) If Not Rng Is Nothing Then Rng.EntireRow.Delete End If Loop While Not Rng Is Nothing Application.ScreenUpdating = True Range("FF92").Select Selection.End(xlDown).Select MsgBox "Removed 0's ROWS from column FG--calculating now--please wait" Application.Calculation = xlAutomatic End Sub
This comment was minimized by the moderator on the site
Hi dears , I need a code to hide the rows which have the value=0 on the column "N" in the sheet 1. The value of the column "N" will change when update the details on the Sheet 2. that's the time need to un-hide the row. is this possible to do this with Excel formula(without macro and Excel Filters).
This comment was minimized by the moderator on the site
This didn't work for me. It changed all values in my chosen column and the adjacent column to zeros. I must be doing something wrong!
This comment was minimized by the moderator on the site
Hi Sheri,
The code works well in my case. Which Excel verson do you use?
This comment was minimized by the moderator on the site
Hi Crystal. I posted this two years ago so I’m guessing I figured it out. But thanks for the reply.
This comment was minimized by the moderator on the site
Insert this in VB new module.
This is with InputBox to delete row which contains that word.

Attribute VB_Name = "FindDelRowByWord"
Sub FindDelRow()
'Updateby20140616
Dim Rng As Range
Dim WorkRng As Range
Dim xRep As String
On Error Resume Next
xTitleId = "ZOK Tools"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
xRep = Application.InputBox("word to delete Row:", "ZOK Tools", , , , , 2)
Application.ScreenUpdating = False
Do
Set Rng = WorkRng.Find(xRep, LookIn:=xlValues)
If Not Rng Is Nothing Then
Rng.EntireRow.Delete
End If
Loop While Not Rng Is Nothing
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
WHAT IF you have a big sheet, and there are rows you want to keep, and others rows that contain certain key words and delete those? the kutools work for me but for one key word that many rows have that key word, the rows were deleted, i just want to have multiple key words to do the same? does this work for the code above?
This comment was minimized by the moderator on the site
Good Day,
Kutools can deal with two key words at the same time. You need to enable its second condition with "And" or "Or". Hope I can help.
There are no comments posted here yet
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations