当我尝试使用For
Step -1
循环会一直跳过
Dim locRow as Integer, lastRow as Integer, i as Integer
locRow = 1
lastRow = 10
for i = (locRow + 1) to lastRow Step -1
If IsEmpty(.Cells(i,1)) Then
Rows(i).EntireRow.delete
End if
Next i
当我到达For
行时,它会完全跳过循环部分。如果我删除了Step -1
,那么它可以正常运行,但我必须将i = i - 1
添加到我的If()
语句中。我觉得这没关系,但我很好奇为什么退步不起作用。
感谢您的任何想法!
答案 0 :(得分:1)
根据评论:
Dim locRow as Integer, lastRow as Integer, i as Integer
locRow = 1
lastRow = 10
for i = lastRow to (locRow + 1) Step -1
If IsEmpty(.Cells(i,1)) Then
Rows(i).EntireRow.delete
End if
Next i