Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I got an "Overflow" error in one of my Progress Bar. When debugging the
code, I found out that I am able to reproduce the problem any time. The bar width is 300 points and I want to show progress 200 times. The sample code below reproduce the problem all the time. Can someone tell me what is wrong? By the way, I am using Ms-Office Excel 2003 SP3. Sub CheckOverflow() Dim i As Integer Dim r As Integer r = 200 On Error Resume Next For i = 1 To r Err.Clear Cells(i, 1) = 300 * (i - 1) / r If Err Then Cells(i, 1) = Error(Err) 'Call MyMacro() Next i End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try using
Dim i As Long The overflow occurs when computing the new cell value beyond the limit of the integer range for i. -- Regards, Nigel "René" wrote in message ... I got an "Overflow" error in one of my Progress Bar. When debugging the code, I found out that I am able to reproduce the problem any time. The bar width is 300 points and I want to show progress 200 times. The sample code below reproduce the problem all the time. Can someone tell me what is wrong? By the way, I am using Ms-Office Excel 2003 SP3. Sub CheckOverflow() Dim i As Integer Dim r As Integer r = 200 On Error Resume Next For i = 1 To r Err.Clear Cells(i, 1) = 300 * (i - 1) / r If Err Then Cells(i, 1) = Error(Err) 'Call MyMacro() Next i End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Works fine
Thanks Nigel "Nigel" wrote: Try using Dim i As Long The overflow occurs when computing the new cell value beyond the limit of the integer range for i. -- Regards, Nigel "René" wrote in message ... I got an "Overflow" error in one of my Progress Bar. When debugging the code, I found out that I am able to reproduce the problem any time. The bar width is 300 points and I want to show progress 200 times. The sample code below reproduce the problem all the time. Can someone tell me what is wrong? By the way, I am using Ms-Office Excel 2003 SP3. Sub CheckOverflow() Dim i As Integer Dim r As Integer r = 200 On Error Resume Next For i = 1 To r Err.Clear Cells(i, 1) = 300 * (i - 1) / r If Err Then Cells(i, 1) = Error(Err) 'Call MyMacro() Next i End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The solution to declare the variables as "Long" works fine.
But I've tried 2 new and very basic tests and I still get the error. Test #1 Sub CheckOverflow2() MsgBox 300 * (111 - 1) / 200 End Sub Test#2 Sub BasicTest() MsgBox CheckOverflow3() End Sub Function CheckOverflow3() As Long CheckOverflow2 = 300 * (111 - 1) / 200 End Function "Nigel" wrote: Try using Dim i As Long The overflow occurs when computing the new cell value beyond the limit of the integer range for i. -- Regards, Nigel "René" wrote in message ... I got an "Overflow" error in one of my Progress Bar. When debugging the code, I found out that I am able to reproduce the problem any time. The bar width is 300 points and I want to show progress 200 times. The sample code below reproduce the problem all the time. Can someone tell me what is wrong? By the way, I am using Ms-Office Excel 2003 SP3. Sub CheckOverflow() Dim i As Integer Dim r As Integer r = 200 On Error Resume Next For i = 1 To r Err.Clear Cells(i, 1) = 300 * (i - 1) / r If Err Then Cells(i, 1) = Error(Err) 'Call MyMacro() Next i End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Overflow error, need help | Excel Programming | |||
Overflow Error | Excel Discussion (Misc queries) | |||
Overflow Error | Excel Programming | |||
Overflow error | Excel Programming | |||
Help! Overflow Error 6 | Excel Programming |