继续为不起作用
我试图在Excel中使用Continue For语句,它会引发一个编译错误:“Expected expression”。 这是代码:
For i = 3 To num If Cells(i, 19) = "" Then continue for End If Next i
为什么会这样呢? PS:这是实际代码的简化版本。
最简单的就是在条件不满足时简单地处理。
For i = 3 To num If Cells(i, 19) <> "" Then 'execute the rest of the processing End If Next i
避免在For Next循环中增加i
。 GoTo
是不鼓励的,而且在很大程度上是不必要的(如上所示)。
如果值是types化的值,并且不是从公式返回的,则替代项将是xlCellTypeConstants的Range.SpecialCells方法中的For Each。