ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Macro needed to identify value and delete row if value below targe (https://www.excelbanter.com/new-users-excel/213008-macro-needed-identify-value-delete-row-if-value-below-targe.html)

Pyrotoy

Macro needed to identify value and delete row if value below targe
 
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.

Rick Rothstein

Macro needed to identify value and delete row if value below targe
 
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

--
Rick (MVP - Excel)


"Pyrotoy" wrote in message
...
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.



Gary''s Student

Macro needed to identify value and delete row if value below targe
 
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

--
Gary''s Student - gsnu200819

Pyrotoy

Macro needed to identify value and delete row if value below t
 
Rick: Works perfectly. Thanks for the fast response. Best wishes, Scott

"Rick Rothstein" wrote:

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

--
Rick (MVP - Excel)


"Pyrotoy" wrote in message
...
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.





All times are GMT +1. The time now is 09:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com