我已經編寫了嵌套的For循環,即使條件滿足,也不會執行For循環的代碼。我試着評論最外面的For循環,但內循環也不起作用。 我在Excel工作2007Excel 2007中的VBA不會執行嵌套for循環
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)'? – 2014-09-18 19:16:40