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