Macro needed to identify value and delete row if value below targe

P

Pyrotoy

I need a macro that will locate a numeric value in column J only, and if that
value is less than 15, the entire row on which that value is located will be
deleted. Thank you.
 
R

Rick Rothstein

Give this macro a try...

Sub RemoveRowsLessThan15()
Dim X As Long
With Worksheets("Sheet1")
For X = .UsedRange.Rows.Count To 1 Step -1
If IsNumeric(.Cells(X, "J").Value) Then
If .Cells(X, "J").Value < 15 Then .Rows(X).Delete
End If
Next
End With
End Sub
 
G

Gary''s Student

Sub killsmall()
n = Cells(Rows.Count, "J").End(xlUp).Row
For j = n To 1 Step -1
If Cells(j, "J").Value < 15 Then
Cells(j, "J").EntireRow.Delete
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top