LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Declaration problem


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 memor
space to the product value. And since "integer" has an upper limit o
32767, the code crashes at x=2 (which produces 60,000). But shouldn'
Excel be concerned with allocating memory space to x over the rang
1-1000 in this instance? I would welcome an explanation.

TI

--
david
-----------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...fo&userid=2064
View this thread: http://www.excelforum.com/showthread.php?threadid=39800

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Declaration problem Shawn Excel Programming 2 July 17th 05 10:44 PM
Declaration name Robert Hargreaves[_2_] Excel Programming 4 June 6th 05 04:48 PM
duplicate declaration [email protected] Excel Programming 1 March 1st 05 02:03 AM
which declaration to use Peer Excel Programming 3 August 2nd 04 03:17 PM
Declaration? TJF[_2_] Excel Programming 5 December 18th 03 03:26 PM


All times are GMT +1. The time now is 01:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"