无效的下一个控制变量引用ERROR

时间:2016-10-13 08:42:47

标签: vba loops next

我正在编写代码,但是我得到了Invalid Next控件变量引用错误,我不知道为什么。这是我的代码:

1 个答案:

答案 0 :(得分:0)

你的i和j变量是错误的方法,你需要确保正确的变量是正确的缩进。希望这有帮助!

Sub Network()

Dim Net(1 To 8) As Double
Dim Total(1 To 8) As Double
Dim i As Integer


For i = 1 To 8
    For j = 1 To 5

        Net(j) = Worksheets("Summary").Cells((i * 7) + 12, 9).Value

    Next j
Next i



For j = 1 To 5

    Total(j) = WorksheetFunction.Sum(Net(j))

Next j

For j = 1 To 5

    Worksheets("Summary").Cells(73, 8 + j) = Total(j)

Next j


End Sub