View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
René[_2_] René[_2_] is offline
external usenet poster
 
Posts: 24
Default Overflow error in Progress Bar

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