【发布时间】:2014-11-13 06:03:51
【问题描述】:
我编写了嵌套的 For 循环,即使满足条件,它也不会执行 For 循环的代码。我尝试注释掉最外面的 For 循环,但内部循环也不起作用。 我正在使用 Excel 2007
Sub CalcAll()
Dim a As Integer
a = 10
Dim b As Integer
b = 10
For a = 10 To a = (Range("B" & Rows.Count).End(xlUp).Row) Step 1
For b = 10 To b = (Worksheets("DistanceLookupTable").Cells(2, Sheet1.Columns.Count).End(xlToLeft).Column) Step 1
If IsEmpty(Cells(a, i).Value) Then
Exit Sub
Else
'Lots of code reading values from the worksheet and printing
'calculated values to the worksheet
End If
Next b
Next a
End Sub
感谢您的帮助
【问题讨论】:
-
您有
Cells(a, i),但没有定义i。应该是Cells(a, b)?
标签: excel vba for-loop nested-loops execution