excelVBA中,下标越界是什么意思(下面有详细的,求高手帮助!!)
A列数据有18635条,是统计该列数据连续1次...到连续10次的数值和,VBA是:PrivateSubCommandButton1_Click()Dimi,j,k,m,...
A列数据有18635条,是统计该列数据连续1次...到连续10次的数值和,VBA是:
Private Sub CommandButton1_Click()
Dim i, j, k, m, a(1 To 10) As Integer
j = 0
Cells(Range("A65536").End(xlUp).Row + 1, 1) = 0
For i = 1 To Range("A65536").End(xlUp).Row
If Cells(i, 1).Value = 0 Then
m = j
For k = i - j + 1 To i
a(m) = a(m) + Cells(k - 1, 1).Value
Next k
j = 0
Else
j = j + 1
End If
Next i
For k = 1 To 10
Cells(2, k + 2) = a(k)
Next k
Cells(Range("A65536").End(xlUp).Row, 1) = ""
End Sub
数据不多时可以计算,多了就这样,不明白??? 展开
Private Sub CommandButton1_Click()
Dim i, j, k, m, a(1 To 10) As Integer
j = 0
Cells(Range("A65536").End(xlUp).Row + 1, 1) = 0
For i = 1 To Range("A65536").End(xlUp).Row
If Cells(i, 1).Value = 0 Then
m = j
For k = i - j + 1 To i
a(m) = a(m) + Cells(k - 1, 1).Value
Next k
j = 0
Else
j = j + 1
End If
Next i
For k = 1 To 10
Cells(2, k + 2) = a(k)
Next k
Cells(Range("A65536").End(xlUp).Row, 1) = ""
End Sub
数据不多时可以计算,多了就这样,不明白??? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询