部署两个工作表时,下标超出范围错误

时间:2017-06-06 16:57:58

标签: excel vba excel-vba

我是VBA的新手,试图在一个工作簿下的两个工作表之间进行游戏。为什么以下代码一直给我“下标超出范围”错误?

Sub mon()


Dim i As Integer
Dim k As Integer
Dim s As Double
Dim rep As String

For i = 1 To 10000

    If Worksheets("Holding Extract to Excel").Cells(i, 31).Value > 1 Then

    ActiveWorkbook.Worksheets("Monitor").Cells(i, 1).Value = ActiveWorkbook.Worksheets("Holding Extract to Excel").Cells(i, 1).Value
    ActiveWorkbook.Worksheets("Monitor").Cells(i, 2).Value = ActiveWorkbook.Worksheets("Holding Extract to Excel").Cells(i, 10).Value
    Worksheets("Monitor").Cells(i, 3).Value = Worksheets("Holding Extract to Excel").Cells(i, 31).Value

    k = k + Worksheets("Monitor").Cells(i, 3).Value

    End If

Next i

Dim Total As Range
Set Total = Range(Cells(1, 5))

Worksheets("Monitor").Range("Total").Value = k


End Sub

0 个答案:

没有答案