Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default How do I get a UDF to return existing value rather than recalc

I need to get a UDF to sometimes return its existing value rather than
recalc. I am happy for the function to be called but need some way of 1)
bypassing the full calc - (clearly trivial) and then 2) returning the value
that was already there before the calculation attempt (much harder!)

This is really for speed increases. I have a set of Excel functions that
query an Access based app and users typically have many huindreds of calls in
a single wrokbook. The underlying data in the mdb only changes occasionally
(but unpredictably)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How do I get a UDF to return existing value rather than recalc

Declare a public global variable (outside the UDF). Have the UDF store its
return value in this variable whenever it exists.

Pass a boolean flag to the UDF as an argument. The coding in the UDF would
examine the flag. If true, do the calculation; if false, just pickup the
value in the global variable and return that value.
--
Gary's Student


"RobC" wrote:

I need to get a UDF to sometimes return its existing value rather than
recalc. I am happy for the function to be called but need some way of 1)
bypassing the full calc - (clearly trivial) and then 2) returning the value
that was already there before the calculation attempt (much harder!)

This is really for speed increases. I have a set of Excel functions that
query an Access based app and users typically have many huindreds of calls in
a single wrokbook. The underlying data in the mdb only changes occasionally
(but unpredictably)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default How do I get a UDF to return existing value rather than recalc

Thanks for this. As it stands this won't work as users make 00's of calls to
the same function in any given workbook. We considered a variation of this -
effectively "caching" all function call returns in an array. This is very
iffy and gives rise to major synchronisation problems (i.e trapping worksheet
manipulation etc)


What I really need is some way for a function to know its own value at the
instant before the calculation process fires


"Gary''s Student" wrote:

Declare a public global variable (outside the UDF). Have the UDF store its
return value in this variable whenever it exists.

Pass a boolean flag to the UDF as an argument. The coding in the UDF would
examine the flag. If true, do the calculation; if false, just pickup the
value in the global variable and return that value.
--
Gary's Student


"RobC" wrote:

I need to get a UDF to sometimes return its existing value rather than
recalc. I am happy for the function to be called but need some way of 1)
bypassing the full calc - (clearly trivial) and then 2) returning the value
that was already there before the calculation attempt (much harder!)

This is really for speed increases. I have a set of Excel functions that
query an Access based app and users typically have many huindreds of calls in
a single wrokbook. The underlying data in the mdb only changes occasionally
(but unpredictably)

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
Recalc Time CLR Excel Programming 5 November 15th 05 08:36 PM
Automatic Recalc DME Excel Worksheet Functions 1 March 21st 05 08:05 PM
Automatically paste cells that return a value, otherwise maintain existing formula. Cameron Stewart Excel Programming 2 July 23rd 04 10:35 AM
Automatically paste cells that return a value, otherwise maintain existing formula. Cameron Stewart Excel Programming 0 July 22nd 04 06:40 AM
recalc question Bura Tino Excel Programming 2 July 10th 03 02:47 PM


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