Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ep ep is offline
external usenet poster
 
Posts: 15
Default stop redundant calls to UDF

Hi All

I have an Excel 2003 UDF that I want called exactly once. Here's one I'll
use as an example:

public int MySum(object cells)
{
int sum = 0;
foreach(Excel.Range range in ((Excel.Range)cells))
{
sum += Convert.ToInt32(range.Value2);
}
return sum;
}

In my Excel worksheet, I have a cell containing the formula: =MySum(A1:A3),
with A1:A3 each containing the volatile function =rand()

The problem is, with the calculation mode set to Automatic, MySum gets
called a total of 4 times, one for the initial call to MySum and once for
each time a new random number is generated. I could set the calc mode to
Manual, but at some point I need to set it back to Automatic, and at that
point it will perform the extra calls to MySum.

My question is, is there anyway I can have MySum called only once, but end
up in Excel Auto calculation mode? All suggestions are greatly appreciated.
Let me know if I need to clarify anything. Thanks

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
Redundant data ale Excel Discussion (Misc queries) 1 May 14th 07 06:51 PM
Redundant Striker Excel Programming 1 August 23rd 06 01:46 PM
minimizing redundant code dreamz[_31_] Excel Programming 4 March 10th 06 08:17 PM
finding redundant data eternal_cat via OfficeKB.com Excel Worksheet Functions 1 December 8th 05 07:53 AM
Redundant Subtotal Level kmbarz Excel Programming 1 June 29th 05 07:28 PM


All times are GMT +1. The time now is 12:38 PM.

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

About Us

"It's about Microsoft Excel"