Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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


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

strong>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 the full feature 60-day free trail of Kutools for Excel now!

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download the free trial Now!


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


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.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days. 

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 of this utility, please go to free download the software first, and then go to apply the operation according above steps.


Office Tab - Tabbed Browsing, Editing, and Managing of Workbooks in Excel:

Office Tab brings the tabbed interface as seen in web browsers such as Google Chrome, Internet Explorer new versions and Firefox to Microsoft Excel. It will be a time-saving tool and irreplaceble in your work. See below demo:

Click for free trial of Office Tab!

Office Tab for Excel


Delete row if cell contains zero with Kutools for Excel

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 60 days. Download the free trial now!


Relative Articles:


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Guest · 3 months ago
    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
    • To post as a guest, your comment is unpublished.
      AndrewRosales · 3 months ago
      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?
      • To post as a guest, your comment is unpublished.
        crystal · 3 months ago
        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.
  • To post as a guest, your comment is unpublished.
    Sheri · 2 years ago
    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!
    • To post as a guest, your comment is unpublished.
      crystal · 3 months ago
      Hi Sheri,
      The code works well in my case. Which Excel verson do you use?
      • To post as a guest, your comment is unpublished.
        Sheri Dohm · 3 months ago
        Hi Crystal. I posted this two years ago so I’m guessing I figured it out. But thanks for the reply.
  • To post as a guest, your comment is unpublished.
    R. Arunkumar · 2 years ago
    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).
  • To post as a guest, your comment is unpublished.
    J Murphy · 3 years ago
    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
  • To post as a guest, your comment is unpublished.
    Andrew · 3 years ago
    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