View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
egun egun is offline
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 - )