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

Delete rows if cell is greater/less than a certain value with VBA code

Delete rows if cell is greater/less than a certain value with Kutools for Excel

Delete rows if cell is greater/less than a certain value with Kutoos for Excel


Select entire rows if cell is greater or less than a certain value in a column

The Select Specific Cells utility of Kutools for Excel can help you easily selecting the entire rows in specified range if cell is greater or less than a certian value in a certain column. See screenshot below:

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

Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.

Delete rows if cell is greater/less than a certain value with VBA code


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.


Delete rows if cell is greater/less than a certain value with Kutools for Excel

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.

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

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.


Delete rows if cell is greater/less than a certain value with Kutoos for Excel

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.

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

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.


Delete rows if cell is greater/less than a certain value 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!


Related articles:


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.
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
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.
    karolina.n28 · 2 years ago
    Hi! How can I change your code (Delete Rows If Cell Is Greater/Less Than A Certain Value With VBA Code) if I would like it to work in every sheet in a workbook?
    I need it to delete the rows if date in column A is