Sub NewRefesh()
If Not Range("X2") = "COMPLETE" Or Range("X2") = "CANCELLED" Then
Range("X2").Select
ActiveCell.FormulaR1C1 = "=GetOrderStatus(RC[1])"
End If
End Sub
以上代码仅适用于X2,但我希望在X52之前完成。
(例如:下一次检查X3 =完成“或范围(”X3“)=”取消“然后 范围( “X3”)。选择 ActiveCell.FormulaR1C1 =“= GetOrderStatus(RC [1])”并执行操作,接下来是X4,依此类推
答案 0 :(得分:1)
我认为在你的帖子中你的意思是:
注意:最好远离ActiveCell
和Range
,而是使用引用的Range("X" & i).FormulaR1C1
。在您的代码中,您可以直接使用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
<强>代码强>
from itertools import cycle
with open('test_file','r') as tf, open('keyword_file', 'r') as kf:
keywords = [k.strip() for k in kf]
for lineno, line in enumerate(tf):
for i, key in enumerate(cycle(keywords)):
if i==len(keywords):
break
if key in line.strip():
print "Keyword: '"+key+"' found on line: "+str(lineno)
答案 1 :(得分:0)
使用行/列号
x是第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