J
JimFor
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
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