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.
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.
3. In the Custom AutoFilter dialog box, enter number 0 into the textbox as below screenshot shown, and then click the OK button.
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:
5. Now all visible rows are deleted. You can click Data > Filter again to show all data without zero value cells. See screenshot:
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)
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:
Then all rows based on the zero values in specified column range are deleted immediately.
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:
Now all rows with the zero values exist in the specified column are deleted immediately. See screenshot: