Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overflow Error 6

Status
Not open for further replies.

OverFlow

IS-IT--Management
May 15, 2002
4
DE
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 forget is Double larger than long.

The other way to do it is to set it to currency, that will allow many more numbers. Craig, mailto:sander@cogeco.ca

Remember not to name the Lambs...
It only makes the chops harder to swallow
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top