Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Controlling execution of a Sub Procedure

I have a spreadsheet that itself has a recursive (iteration) loop. Once the
sheet converges, I have to look at the results and depending on what they
are, either call a lengthy Sub procedure or bypass it. I cannot use Function
procedures because the lengthy calculation I must perform is itself
iterative. Thus I can't break up the calculation into a number of small
Function procedures. I am now using the worksheet_calculate() event handler,
but evidently the definition of "recalculate the spreadsheet" includes any
cell that is manipulated. Thus what I am running into is the
Worksheet_calculate() sub procedure is being called over and over until the
stack overflows, EVEN though the TEST spreadsheet I am using has only one
cell of data that I change and one calculation. Everything else is static.
Anyone have ANY suggestions around this problem? Any way to call a sub
procedure from the spreadsheet itself? I am using Excel 2003 with all the
patches and updates.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Controlling execution of a Sub Procedure


There's a few reasons for getting stack overflow, it could be that your
procedure is changing the worksheet which triggers a sheet
change/calculation which starts he procedure anew. It could also be that
your recursive procedure does not have adequate exit strategies.

Is your recursive procedure truly recursive (that is, it calls itself,
or is it just iterative as in a loop of some sort?

Give us some meat to work on, post some code etc.

ps. There's no reason a vba function can't call itself, recursively,
iteratively or any other way, whether it passes arguments or not.

I looked up 'recursion' in the dictionary and all I got was: 'see
Recursion'.


Don McC;703105 Wrote:

I have a spreadsheet that itself has a recursive (iteration) loop.
Once the
sheet converges, I have to look at the results and depending on what

they
are, either call a lengthy Sub procedure or bypass it. I cannot use

Function
procedures because the lengthy calculation I must perform is itself
iterative. Thus I can't break up the calculation into a number of

small
Function procedures. I am now using the worksheet_calculate() event

handler,
but evidently the definition of "recalculate the spreadsheet" includes

any
cell that is manipulated. Thus what I am running into is the
Worksheet_calculate() sub procedure is being called over and over until

the
stack overflows, EVEN though the TEST spreadsheet I am using has only

one
cell of data that I change and one calculation. Everything else is

static.
Anyone have ANY suggestions around this problem? Any way to call a

sub
procedure from the spreadsheet itself? I am using Excel 2003 with all

the
patches and updates.

Thanks



--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?u=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=196715

http://www.thecodecage.com/forumz

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Controlling execution of a Sub Procedure

The problem was in the posting back of results to the same page. Once I
wrote back the results of the Worksheet_calculate() sub procedure to another
page it worked fine. You wouldn't have wanted me to post the code. I
basically had to duplicate one whole spreadsheet within code, so the code was
about 7 standard pages worth....I sure wish excel had a way to control
execution of parts (ranges) of cells better. Worksheet_change and
Worksheet_calculate don't always work very elegantly.

"p45cal" wrote:


There's a few reasons for getting stack overflow, it could be that your
procedure is changing the worksheet which triggers a sheet
change/calculation which starts he procedure anew. It could also be that
your recursive procedure does not have adequate exit strategies.

Is your recursive procedure truly recursive (that is, it calls itself,
or is it just iterative as in a loop of some sort?

Give us some meat to work on, post some code etc.

ps. There's no reason a vba function can't call itself, recursively,
iteratively or any other way, whether it passes arguments or not.

I looked up 'recursion' in the dictionary and all I got was: 'see
Recursion'.



Don McC;703105 Wrote:

I have a spreadsheet that itself has a recursive (iteration) loop.
Once the
sheet converges, I have to look at the results and depending on what

they
are, either call a lengthy Sub procedure or bypass it. I cannot use

Function
procedures because the lengthy calculation I must perform is itself
iterative. Thus I can't break up the calculation into a number of

small
Function procedures. I am now using the worksheet_calculate() event

handler,
but evidently the definition of "recalculate the spreadsheet" includes

any
cell that is manipulated. Thus what I am running into is the
Worksheet_calculate() sub procedure is being called over and over until

the
stack overflows, EVEN though the TEST spreadsheet I am using has only

one
cell of data that I change and one calculation. Everything else is

static.
Anyone have ANY suggestions around this problem? Any way to call a

sub
procedure from the spreadsheet itself? I am using Excel 2003 with all

the
patches and updates.

Thanks



--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?u=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=196715

http://www.thecodecage.com/forumz

.

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
Certain methods stop procedure execution without notification mrbarritt Excel Programming 2 September 14th 09 11:40 AM
why does the execution jump to another procedure? Harold Good Excel Programming 4 May 14th 09 02:21 PM
Time the Execution Speed of Procedure in Milliseconds RyanH Excel Programming 1 August 24th 08 10:44 PM
Blank Message Box after procedure execution [email protected] Excel Programming 7 June 1st 07 01:13 PM
controlling macro execution sree Excel Programming 1 February 21st 05 01:51 AM


All times are GMT +1. The time now is 02:20 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"