Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Out of Stack Space error

Hi,

I have a program which has a User form. and which uses multiple IF statements
to determine what to do. The user enters FirstDate, SecondDate and number of
transactions to look at (NoToFill). It uses a counter to check the cell value
on one sheet and, depending on what that cell value is, does a variety of
things. Hence, the multiple IF statements. As of now I have been unable to
execute any IF statement beyond the first two. Here is a brief bit of code:
The format for the cells is General.

'Main program
Public Sub Jim()
Count = 1

For i = 1 To NoToFill
Count = Count + 1
'If first transaction then set up first line on Sheet3
If Count = 2 Then Mary1
'If other than first transactions and date on sheet2 before date entered by
user go to Fred
If Worksheets("Sheet2").Cells(Count, 2) < FirstDate Then Fred
'If other than first transactions and date on sheet2 within dates entered by
user go to Jane
If Worksheets("Sheet2").Cells(Count, 2) = FirstDate And
Worksheets("Sheet2").Cells(Count, 2) <= SecondDate Then Jane

Next i

End Sub

I can get results from "Mary1" and "Fred" but "Jane" never seems to process
anything. The error I receive is an Out of Stack Space error. Mary1 and Fred
do process if I do not enter dates. However, when I enter dates and the
program is supposed to calculate based upon the date criteria, I get an Out of
Stack error and an arrow appears next to the If Count=2 Then Mary1 line. Can
anyone tell me what might be wrong and what I should do to correct it?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Out of Stack Space error


There are too many unexplained variables in your sub.
It is therefore difficult to understand what is going on.
The following is one way it could be set up...
'-------------------------------------
Option Explicit

Public Sub Jim(ByRef NoToFill As Long, ByRef FirstDate As Date, _
ByRef SecondDate As Date)
Dim i As Long

' keep things within reason
For i = 2 To WorksheetFunction.Max(NoToFill, 1000)

If i = 2 Then
Mary1
ElseIf Worksheets("Sheet2").Cells(i, 2).Value < FirstDate Then
Fred
ElseIf (Worksheets("Sheet2").Cells(i, 2).Value = FirstDate) And _
(Worksheets("Sheet2").Cells(i, 2).Value <= SecondDate) Then
Jane
End If

Next i
End Sub
'-----------------------------------
Jim Cone
San Francisco, USA


"JimFor" wrote in message
...
Hi,
I have a program which has a User form. and which uses multiple IF statements
to determine what to do. The user enters FirstDate, SecondDate and number of
transactions to look at (NoToFill). It uses a counter to check the cell value
on one sheet and, depending on what that cell value is, does a variety of
things. Hence, the multiple IF statements. As of now I have been unable to
execute any IF statement beyond the first two. Here is a brief bit of code:
The format for the cells is General.


'Main program
Public Sub Jim()
Count = 1
For i = 1 To NoToFill
Count = Count + 1
'If first transaction then set up first line on Sheet3
If Count = 2 Then Mary1
'If other than first transactions and date on sheet2 before date entered by
user go to Fred
If Worksheets("Sheet2").Cells(Count, 2) < FirstDate Then Fred
'If other than first transactions and date on sheet2 within dates entered by
user go to Jane
If Worksheets("Sheet2").Cells(Count, 2) = FirstDate And
Worksheets("Sheet2").Cells(Count, 2) <= SecondDate Then Jane
Next i
End Sub


I can get results from "Mary1" and "Fred" but "Jane" never seems to process
anything. The error I receive is an Out of Stack Space error. Mary1 and Fred
do process if I do not enter dates. However, when I enter dates and the
program is supposed to calculate based upon the date criteria, I get an Out of
Stack error and an arrow appears next to the If Count=2 Then Mary1 line. Can
anyone tell me what might be wrong and what I should do to correct it?
Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Out of Stack Space error

Thanks. I'll try that. And yes, I know the program as it is written is
complex. What I have been trying to do is get the thing to run and then work on
my refining techniques later.

If this is helpful in any way, this is the general outline of what I am trying
to do. But I warn you, the following is rather long. And it is a bit basic.

I have three sheets of data. The first contains account numbers and account
inventory numbers for the end of a year.

The second page consists of transaction data for accounts, some of which appear
on sheet1 and some of which do not. The transaction data is basically account
unit sales and purchases by individual dates for a period of time.

One might look at it this way. I'm trying to determine the inventory status
and transaction type for each account for a period of time. The computer
program which provides the data does not keep a running total of inventor
amounts. So I can't just ask it to tell me what transactions occurred within a
period as well as tell me what the beginning and ending inventory amounts are.
I must build them up myself.

Let's say I need account transaction data for the period 2/2/01 through
2/2/02. I have to first get the ending inventory for the period 12/31/01. That
would be from sheet1. The computer program now used just keeps end of year
inventory data. Then I must add and subtract from that ending inventory
amount all units an account bought and sold for the period 1/1/01 through
2/1/01. That is the beginning inventory amount for that account. That goes on
sheet3.

Next I have to add and subtract all the units the account purchased and sold
during the period 2/2/01 through 2/2/02 from the beginning inventory amount.
That give me the account ending inventory amount. I transfer the individual
transaction data, as well as the ending inventory amount for that account, to
sheet3 and put that data under the beginning inventory amount. Repeat for each
account which had transaction data for that period.

The user inputs the two dates as well as the total number of accounts which
appears on sheet1 (for VLOOKUP purposes). The computer should do the rest.
I''ve written the various parts of the program which will do each task and
tested each individually on dummy data. They seem to work. However, when I try
to put the thing together, and add some more complexity, some things don't
work. I'm in the process of fixing them.

Thanks for the help.
Reply
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
Out of Stack Space error TheMilkGuy Excel Discussion (Misc queries) 2 July 22nd 09 05:54 PM
Out of Stack space - run time error 28 Rob Excel Discussion (Misc queries) 2 December 17th 07 04:55 PM
"Out of Stack Space" Macro Error Adam Excel Discussion (Misc queries) 3 July 2nd 07 07:10 PM
Run time error 28: Out of stack space Will Wirtz Excel Programming 1 April 27th 04 01:39 PM
Run Time Error "28" - Out of stack space? Tom Ogilvy Excel Programming 0 September 12th 03 04:43 PM


All times are GMT +1. The time now is 09:16 PM.

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

About Us

"It's about Microsoft Excel"