View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
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)