I have a program to solve packing problem 3D. When I run the program with only 100 rows of data my code works, but when I use all my data I have an error:
Run-time error '6':
Overflow
Here is my code:
If rotationtype = 2 Then
Do While Worksheets(6).Cells(xrow, xcolumn).Value <> ""
' 0,1 > inputan
If Worksheets(6).Cells(xrow, xcolumn).Offset(0, 1).Value > Worksheets(6).Cells(xrow, xcolumn).Value Then
Worksheets(6).Cells(xrow, xcolumn).Offset(0, 3).Value = Worksheets(6).Cells(xrow, xcolumn).Offset(0, 1).Value
Worksheets(6).Cells(xrow, xcolumn).Offset(0, 4).Value = Worksheets(6).Cells(xrow, xcolumn).Value
Worksheets(6).Cells(xrow, xcolumn).Offset(0, 5).Value = Worksheets(6).Cells(xrow, xcolumn).Offset(0, 2).Value
Else ' 0,1 < inputan
Worksheets(6).Cells(xrow, xcolumn).Offset(0, 3).Value = Worksheets(6).Cells(xrow, xcolumn).Value
Worksheets(6).Cells(xrow, xcolumn).Offset(0, 4).Value = Worksheets(6).Cells(xrow, xcolumn).Offset(0, 1).Value
Worksheets(6).Cells(xrow, xcolumn).Offset(0, 5).Value = Worksheets(6).Cells(xrow, xcolumn).Offset(0, 2).Value
End If
xrow = xrow + 1
Loop
Toplamkutusayisi = xrow - 2
xrow = 2
Else
I have 49,606 rows of data:
How can I avoid getting this error?
Did you declare your variables? Soudns like an integer overflow with xrow.
Just add
Dim xrow as long
at the beginning of your Procedure.
From the error, I assume that the problem is in the Worksheets(6)
part.
Do you have 7 work-sheets? Remember: counting starts at 0! Not at 1!
If this is the case, change the index to 7 instead of 6:
Worksheets(7).Cells(xrow, xcolumn).Value
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.