1
I intend to search row by row within the column P:P
a number less than or equal to 200 and execute a command. If more than 200 execute another. The values are defined as 0.0
.
If .Value =< 200 Then
ActiveCell.FormulaR1C1 = "=RC[-5]*1.69*(1+30%)"
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
Range("U2").AutoFill Destination:=Range("U2:U" & Lastrow)
ElseIf .Value > 200 Then
ActiveCell.FormulaR1C1 = "=RC[-5]*1.69*(1+40%)"
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
Range("U2").AutoFill Destination:=Range("U2:U" & Lastrow)
End If
REPLY:
Sub teste()
Dim rng As Range
Set rng = Range("P1:P300") 'Se colocar P:P vai até à última linha
For Each Row In rng.Rows
If Row.Value < "200" Then
Range("U2").Select
ActiveCell.FormulaR1C1 = "=RC[-5]*1.69*(1+30%)"
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
Range("U2").AutoFill Destination:=Range("U2:U" & Lastrow)
Selection.NumberFormat = "0"
ElseIf Row.Value >= "200" Then
Range("U2").Select
ActiveCell.FormulaR1C1 = "=RC[-5]*1.69*(1+40%)"
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
Range("U2").AutoFill Destination:=Range("U2:U" & Lastrow)
Selection.NumberFormat = "0"
End for
End If
Next Row
End Sub
What is the doubt?
– bfavaretto
I’m not sure how to assign . value to the @bfavaretto column
– b8engl
How do I search row by row within column and compare values?
– b8engl