Reputation: 17
Sub NewRefesh()
If Not Range("X2") = "COMPLETE" Or Range("X2") = "CANCELLED" Then
Range("X2").Select
ActiveCell.FormulaR1C1 = "=GetOrderStatus(RC[1])"
End If
End Sub
The above code does for only X2 but i want do it till X52.
(Ex: Next check in X3 = COMPLETE" Or Range("X3") = "CANCELLED" Then Range("X3").Select ActiveCell.FormulaR1C1 = "=GetOrderStatus(RC[1])"and do the action, next X4 and so on
Upvotes: 0
Views: 221
Reputation: 33692
I think in your post you meant your criteria to be :
Note: it's better to stay away from Select
and ActiveCell
, instead use referenced Range
s. In your code you code directly use Range("X" & i).FormulaR1C1
Code
Option Explicit
Sub NewRefesh()
Dim i As Long
' simple For loop, you can modify to find last row with data instead of 52
For i = 2 To 52
If (Not Range("X" & i).Value = "COMPLETE") And (Not Range("X" & i).Value = "CANCELLED") Then
Range("X" & i).FormulaR1C1 = "=GetOrderStatus(RC[1])"
End If
Next i
End Sub
Upvotes: 1
Reputation: 11
use row/col numbering
x is Column number 24
for i = 2 to 52
If Not cells(i,24) = "COMPLETE" Or cells(i,24) = "CANCELLED" Then
Range(i,24).Select
Whatever you want done.........
End If
Next i
Upvotes: 0