[英]I am getting error 6: overflow. Why?
This is a function that is in my program. 这是我程序中的函数。 In the while loop, i'm getting an overflow.
在while循环中,我溢出了。 Why?
为什么? How do i fix this?
我该如何解决?
Sub durationhours(ByVal sheetname As String, ByVal counter60M As Integer)
Dim j As Integer, matchcounter As Integer, k As Integer, runningtotal As Integer
j = 8: matchcounter = 0: runningtotal = 0
For counter = 7 To counter60M
While Worksheets(sheetname).Cells(counter, 2) = Worksheets(sheetname).Cells(j, 2)
j = j + 1
matchcounter = matchcounter + 1
Wend
If IsEmpty(Worksheets(sheetname).Cells(j, 2)) Then j = j + 3
For k = counter To (counter + matchcounter)
runningtotal = runningtotal + Worksheets(sheetname).Cells(counter, 10)
'here is where you do the calculations for the duration hours
Next k
Worksheets(sheetname).Cells(counter, 11) = runningtotal
counter = j: j = j + 1: matchcounter = 0: runningtotal = 0
Next counter
You are most likely getting that error for one (or combination) of three reasons: 您最有可能由于以下三个原因之一(或多个原因)而收到该错误:
1) Your While
loop never escapes 1)你的
While
循环永不逃脱
2) counter60M
is an extremely large number 2)
counter60M
是一个非常大的数字
3) matchcounter
is an extremely large number 3)
matchcounter
是一个非常大的数字
Change 更改
Dim j As Integer, matchcounter As Integer, k As Integer, runningtotal As Integer
To 至
Dim j As Long, matchcounter As Long, k As Long, runningtotal As Long
then you should be fine 那你应该没事的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.