PDA

View Full Version : If 3 times greater than delete row



oliverralph7
07-28-2008, 06:02 AM
I need some help in writing a code that will delete rows where certain criteria are met.

Column W has text in it
Column R has whole numbers in it
Column Q has whole numbers in it


If Column W= TPRFM then
If Column R is 3x greater than Column Q then
Delete Row

Here is what I have so far



Dim jLastRow As Long
Dim j As Integer
jLastRow = Cells(Rows.Count, "U").End(xlUp).Row
For j = jLastRow To 1 Step -1
If Range("W" & j).Value = "TPRFM" Then
.............................................
Range("W" & j).EntireRow.Delete (xlUp)
End If

End If
Next j

AntonioZZZ
07-28-2008, 06:13 AM
i'm just a beginner but i would use the following


Range("W2").select 'suppose you have labels in the first row
do while ActiveCell <> ""
if ActiveCell = "TPRFM" and ActiveCell.Offset(0,1) >= 3 * ActiveCell.Offset(0,2) then
Activecell.Row.Delete
end if
ActiveCell.Offset(1,0).Select
loop


or something like that

Bob Phillips
07-28-2008, 06:18 AM
Dim jLastRow As Long
Dim j As Long
jLastRow = Cells(Rows.Count, "U").End(xlUp).Row
For j = jLastRow To 1 Step -1
If Range("W" & j).Value = "TPRFM" Then
If Cells(j, "R").Value >= Cells(j, "Q").Value * 3 Then

Range("W" & j).EntireRow.Delete (xlUp)
End If
End If
Next j

oliverralph7
07-28-2008, 06:43 AM
It worked like a charm. Thank you so much for your help.

:hi: