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: 100
Default run-time error '6' - overflow - once I declare a pre-used variable name as integer

Excel 2003 on WinXP run-time error '6' - overflow

I'm writing more an more blocks of code on a program that is (or was) acting
as expected. I'm not a programmer by trade or training, so although I know I
should use option explicit on, it isn't one of the habits I've picked up
yet.

I often use a random variable name for loops, and often use the same
variable name in the same sub or in different subs. I'm just starting to
pass more and more information to functions, and I was having trouble with
Excel accepting the transferred parameters unless I declared the sending and
recieving variables explicitly (and the same, of course). One variable that
I need to pass to my function is my loop variable (it refers to a
position/location on a sheet or array).

So, since I use it as an integer in my function, I declared it as an integer
in my main sub. However, when it hits my loop, I now get a run-time error
'6' overflow. Can anyone explain why this happens, and the proper way to
effectively pass that loop variable as an integer to my function?

Many thanks,
Keith

'irrelevant code blocks deleted
Sub AssembleSchedule()

Dim EachDate As Date
Dim EachDay As Integer
'dim the other variables that are passed to my procedure

For EachDay = 1 To 50000 'error occurs here before looping begins;
'error did not occur here
before the dim
'but I had trouble passing
the data to the function
'do stuff
Next

For EachDay = 1 To 50000
'do other stuff
Next

For EachDay = 0 To 14
'do stuff for a target 2-week window of dates
Next

dummyvariable = BatchingSearch(BatchingDaysOut, EachDay,
RemainingCapacity, UseDept)

End sub

Function BatchingSearch(sDaysOut As Integer, sNowDate As Integer,
sRemainingCapacity As Long, CurrDept As String)
'do other stuff
End function




 
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
Run-Time error '91': Object variable of With block variable not set jammin1911 Excel Programming 3 June 6th 06 06:36 PM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
run-time error 6 - overflow Paul Excel Programming 1 November 11th 04 11:09 AM
Run-time error '6' overflow Suzy[_2_] Excel Programming 2 February 13th 04 04:55 PM
Run-time error 6 Overflow FredM Excel Programming 2 January 20th 04 06:05 AM


All times are GMT +1. The time now is 11:51 PM.

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"