I need it to delete the rows if date in column A is
How to delete rows if cell is greater/less than a certain value in Excel?
Sometimes you may need to delete rows if cells in a specified column are greater or less than a certain value in Excel. This article will recommend several methods to deal with this problem.
Recommended Productivity Tools for Excel
Office Tab: Bring powerful tabs to Office (include Excel), just like Chrome, Safari, Firefox and Internet Explorer. Save you half the time, and reduce thousands of mouse clicks for you. 30-day Unlimited Free Trial
Kutools for Excel: Save 71% of your time and solve 82% Excel problems for you. 300+ advanced tools designed for 1500+ work scenario, make Excel much easy and increase productivity immediately.60-day Unlimited Free Trial
Supposing you want to delete entire rows if cell in column D is greater or less than a certain value in Excel. You can run the following VBA code to achieve it.
1. Press Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, click Insert > module. Then copy and paste the below VBA code into the Code window.
VBA code: Delete rows if cell is greater/less than a certain value in Excel
Public Sub ProcessData() Dim xRg As Range Dim xTxt As String On Error Resume Next If ActiveWindow.RangeSelection.Count > 1 Then xTxt = ActiveWindow.RangeSelection.AddressLocal Else xTxt = ActiveSheet.UsedRange.AddressLocal End If Set xRg = Application.InputBox("Please select range:", "Kutools for Excel", xTxt, , , , , 8) If xRg Is Nothing Then Exit Sub If (xRg.Areas.Count > 1) Or (xRg.Columns.Count > 1) Then MsgBox "You can only select one column per time", vbInformation, "Kutools for Excel" Exit Sub End If xRg.Range("A1").EntireRow.Insert Set xRg = xRg.Range("A1").Offset(-1).Resize(xRg.Rows.Count + 1) xRg.Range("A1") = "Temp" xRg.AutoFilter 1, ">30000" Set xRg = Application.Intersect(xRg, xRg.SpecialCells(xlCellTypeVisible)) On Error GoTo 0 If Not xRg Is Nothing Then xRg.EntireRow.Delete End Sub
Note: In the above code, >30000 means that you will delete rows if cells are greater than 30000 in a specified column. If you want to delete rows if cells are less than a certain value, please change the sign > to < and then specified your value.
3. Press F5 key to run the code, in the popping up Kutools for Excel dialog box, select the range (single column) which you will find if cells in this column are greater or less than a certain value. And then click the OK button. See screenshot:
Then all rows with cell value greater than 30000 in column D are deleted immediately.
The Select Specific Cells utility of Kutools for Excel can help you select all rows with cells greater or less than a certain value in a specified column, and then you can manually delete all selected rows at once.
1. Select the column you want to delete rows based on, then click Kutools > Select > Select Specific Cells. See screenshot:
2. In the Select Specific Cells dialog box, please select Entire row in the Selection type section. In the Specific type section, select Greater than or Less than from the first drop-down list, enter the certain value into the next textbox, and then click the OK button.
3. Then a dialog box pops up to tell you how many rows are selected, please click the OK button. And you can see all rows with value greater than 30000 in column D are selected immediately.
4. Right click on one of the selected rows, then click Delete from the right-clicking menu. And all selected rows are deleted.
In addition to the above two methods, you can filter out all rows with cells greater or less than a certain value in a specified column, and then remove all filtered rows with the Delete Hidden (Visible) Rows & Column utility of Kutools for Excel.
1. Select the column header, then click Data > Filter. See screenshot:
2. Click the drop-down arrow in the column you will delete rows based on, then click Number Filters > Greater Than or Less Than as below screenshot:
3. In the Custom AutoFilter dialog box, enter the certain number after the is greater than or is less than box, and then click the OK button.
4. Then all rows with certain cells which are greater or less than a certain value in column D are all filtered out. You can delete all filtered rows by selecting the filtered data and then click Kutools > Delete > Delete Hidden (Visible) Rows & Columns. See screenshot:
5. In the Delete Hidden (Visible) Rows & Columns dialog box, make sure the In Selected Range option is selected in the Look in drop-down list, select Rows in the Delete type section, specify Visible rows option in the Detailed type section, and finally click the OK button.
6. Then all visible rows in selected range are deleted immediately, you can cancel the filter by clicking Data > Filter.
Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 60 days. Download the free trial now!
- How to delete all rows below certain row or active cell in Excel?
- How to delete all rows except the first header row in Excel?