Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Preventing Recursion?

I have two blocks of data on my worksheet: one with monthly dollar amounts,
and another with annual dollar amounts. I am using the Worksheet_Change
event to monitor any changes to either block of data. If the user enters a
monthly amount, then the annual sum is updated. If the user enters an amount
in the annual total cell, then that value is divided by 12 and placed into
each month. The problem is I am getting into a recursion that I don't want.

For example, say the user enters $5,000 for Feb, 2009. The Worksheet_Change
macro then updates the total for 2009 by adding all twelve months' data.
This causes another call to Worksheet_Change (because 2009 changed), which
then tries to spread the 2009 total amount amongst the months. And so on...

I would appreciate any suggestions for preventing this recursion, or even
another (probably easier and smarter) way to do this.

Thanks,

Eric
--
-----------------------
If toast always lands butter-side down, and cats always land on their feet,
what happen if you strap toast on the back of a cat and drop it?
Steven Wright (1955 - )
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Preventing Recursion?

Yes, you can use the EnableEvent property on the Application object. When
your code first go into the event, set this property to False, then when
your code is done, set this property back to True.

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"egun" wrote in message
...
I have two blocks of data on my worksheet: one with monthly dollar
amounts,
and another with annual dollar amounts. I am using the Worksheet_Change
event to monitor any changes to either block of data. If the user enters
a
monthly amount, then the annual sum is updated. If the user enters an
amount
in the annual total cell, then that value is divided by 12 and placed into
each month. The problem is I am getting into a recursion that I don't
want.

For example, say the user enters $5,000 for Feb, 2009. The
Worksheet_Change
macro then updates the total for 2009 by adding all twelve months' data.
This causes another call to Worksheet_Change (because 2009 changed), which
then tries to spread the 2009 total amount amongst the months. And so
on...

I would appreciate any suggestions for preventing this recursion, or even
another (probably easier and smarter) way to do this.

Thanks,

Eric
--
-----------------------
If toast always lands butter-side down, and cats always land on their
feet,
what happen if you strap toast on the back of a cat and drop it?
Steven Wright (1955 - )



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Preventing Recursion?

I learn something new every day! Thank you for your response - that was
exactly what I needed.

Eric

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
Re-starting a project but avoiding recursion??? Dan Excel Programming 3 March 30th 08 10:13 PM
Recursion in VBA macros? Peter Chatterton[_4_] Excel Programming 5 November 27th 06 07:27 PM
Abort recursion Mike NG Excel Programming 2 June 29th 05 09:08 AM
Recursion Mike NG Excel Programming 4 June 2nd 05 11:07 PM
Worksheet_Change Recursion ARGHH! DBAL[_2_] Excel Programming 6 July 1st 04 11:55 PM


All times are GMT +1. The time now is 07:49 AM.

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"