Can someone help clear this for me?
The declaration of the variable x as Integer works perfectly in:
Sub Declaratn()
Dim x as Integer
For x = 1 to 1000
Cells(x,1) = x
Next
End sub
...but produces overflow error at x=2 in:
Sub Declaratn2()
Dim x as Integer
For x = 1 to 1000
Cells(x,1) = x*30000
Next
End sub
My hunch is that Excel seems to evaluate x*30000 and allocates memory space to the product value. And since "integer" has an upper limit of 32767, the code crashes at x=2 (which produces 60,000). But shouldn't Excel be concerned with allocating memory space to x over the range 1-1000 in this instance? I would welcome an explanation.
TIA
Bookmarks