Hi,
I'm using a Do - While Loop to maneuver through
records on an Excel worksheet. The worksheet
has quite a large amount of data (more than 40000 records...)
I used a long variable to reference the row
number of the record. But, I get an overflow
error even before reaching 20000.
The following is the code:
Dim warmUpAr(1 To 3) As Integer
Dim c As Range
Dim counter As Long
For counter = 1 To 3
warmUpAr(counter) = 0
Next counter
counter = 2
shift = 1
Do
Do While ws1.Cells(counter, 5) = 0
counter = counter + 5
If ws1.Cells(counter, 5) = "" Then
Exit Do
End If
Loop
If ws1.Cells(counter, 5) = "" Or IsNull(ws1.Cells(counter, 5)) Then
Exit Do
End If
Do While ws1.Cells(counter, 5) > 0
counter = counter + 2
Loop
Set c = ws1.Cells(counter - 2, 5)
Debug.Print "c: " & c.Value
Debug.Print "R: " & counter - 2
If c > 0 And c < 200 Then
temp = Val(Left(ws1.Cells(counter - 2, 2), 2))
If shift = 1 And temp > 6 Then
shift = 2
ElseIf shift = 2 And temp > 14 Then
shift = 3
End If
warmUpAr(shift) = warmUpAr(shift) + 1
End If
Loop While counter + 10 <= wsLength
I get the error on line Do While ws1.Cells(counter, 5) = 0
I checked if ws1.Cells(counter, 5) had a Null value or if the loop was going out of the boundary. But it was not.
I also found out that depending on when I run the code, I get the overflow error at different rows.
Could somone please help me?
I'm using a Do - While Loop to maneuver through
records on an Excel worksheet. The worksheet
has quite a large amount of data (more than 40000 records...)
I used a long variable to reference the row
number of the record. But, I get an overflow
error even before reaching 20000.
The following is the code:
Dim warmUpAr(1 To 3) As Integer
Dim c As Range
Dim counter As Long
For counter = 1 To 3
warmUpAr(counter) = 0
Next counter
counter = 2
shift = 1
Do
Do While ws1.Cells(counter, 5) = 0
counter = counter + 5
If ws1.Cells(counter, 5) = "" Then
Exit Do
End If
Loop
If ws1.Cells(counter, 5) = "" Or IsNull(ws1.Cells(counter, 5)) Then
Exit Do
End If
Do While ws1.Cells(counter, 5) > 0
counter = counter + 2
Loop
Set c = ws1.Cells(counter - 2, 5)
Debug.Print "c: " & c.Value
Debug.Print "R: " & counter - 2
If c > 0 And c < 200 Then
temp = Val(Left(ws1.Cells(counter - 2, 2), 2))
If shift = 1 And temp > 6 Then
shift = 2
ElseIf shift = 2 And temp > 14 Then
shift = 3
End If
warmUpAr(shift) = warmUpAr(shift) + 1
End If
Loop While counter + 10 <= wsLength
I get the error on line Do While ws1.Cells(counter, 5) = 0
I checked if ws1.Cells(counter, 5) had a Null value or if the loop was going out of the boundary. But it was not.
I also found out that depending on when I run the code, I get the overflow error at different rows.
Could somone please help me?