View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Charles Williams Charles Williams is offline
external usenet poster
 
Posts: 968
Default Help with Range.Value2, Range.Text and UDFs

..Value and .Value2 get set to Empty during a calculation event when the cell
is uncalculated.
see http://www.decisionmodels.com/calcsecretsj.htm

..Text only gets reset after calculation when the formatting layer gets
refreshed. Using .text in Addins or UDFs is dangerous because:
- you may not get the current value if it has not yet been refreshed
- if the user changes the formatting you may get an unexpected value


Charles
___________________________________
The Excel Calculation Site
http://www.decisionmodels.com

"JsjsLim" wrote in message
...

Hi,

I'm creating an Excel application level solution (using AddIn and UDF
classes).

I have 2 UDFs: Cache() and AnotherFunction().

The Cache() function inits/creates a cache on a remote server, which
returns
an ID that can be referenced by AnotherFunction().

The AddIn is set to find all Cache() functions and run them when a
workbook
is loaded (ensure that the caches are initialized on the server). Of
course,
any AnotherFunctions() functions that references the Cache() function will
also update (when the Application.Calculation is set to Auto).

But here's the scenario that's baffling me:

AddIn:
Finds a Cache() function, inserts it. I then do a quick test to check the
values of the range (Range.Value2, Range.Text, Range.Formula), all which
are
correctly populated.

UDF:
Since an AnotherFunction() function refers to the Cache() function, the
AnotherFunction's UDF is executed once the Cache() function returns.
However,
when I try to retrieve the Range.Value2 from the parameter, I get null.
Only
Range.Text and Range.Formula is populated.

Am I missing a step? Why is Value2 null in the UDF, but correctly
populated
in the AddIn?

Please help.

Thanks.