Delete Entire Row Based on a "Greater Than" Number

Bobaree

New Member
Joined
Aug 13, 2014
Messages
41
I have found examples of how to delete a row based on text in a row, but I'm looking for VBA code that will identify rows with a integer that is >5 and then delete the entire row. Suggestions would be greatly appreciated.
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Bobaree

New Member
Joined
Aug 13, 2014
Messages
41
Do I replace "ActiveCell" with the column identifier (C column for example)? The column wiill be variable in length (last row).
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Maybe this will help you:

Code:
Sub Test()
    Dim LR As Long
    Dim r As Long
    With ActiveSheet
        LR = .Range("C" & .Rows.Count).End(xlUp).Row
        For r = LR To 2 Step -1
            With .Range("C" & r)
                If .Value > 5 Then
                    .EntireRow.Delete
                End If
            End With
        Next r
    End With
End Sub

AutoFilter is another possibility and may be considerably quicker depending on the number of rows of data.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,464
Messages
5,596,288
Members
414,052
Latest member
Dual Showman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top