Re: [ExcelDna] Calculating A Step Late

41 views
Skip to first unread message

Naju Mancheril

unread,
May 22, 2013, 12:31:01 PM5/22/13
to exce...@googlegroups.com
My guess is that Excel's dependency calculation is getting confused by the IsMacroType=True.

This function should be extremely simple:
- You shouldn't need IsVolatilie=True
- You shouldn't need IsMacroType=True
- You shouldn't have AllowReference=True for the parameters

If you remove these, then:
- Excel should call your function with the input values
- You should be able to concatenate and return these values

Govert van Drimmelen

unread,
May 22, 2013, 5:10:42 PM5/22/13
to Excel-DNA
Hi,

In addition to Naju's comments, I would be suspicions about using the
COM Automation interface (via the Range type) to read data from the
sheet from inside a UDF.
I would recommend not doing that, and using the C API (via
ExcelReference) instead.

Reading other parts of the sheet via ExcelRefence.GetValue() from
inside an IsMacroType=true function should be tracked properly by
Excel (meaning your calculation should end in a consistent state).
It's a tricky story exactly how the dependency tracking works in that
case, but it has been examined and written up. Using the COM
Automation interface to do this from a UDF context means you might be
venturing into unsupported, undocumented and poorly understood
territory. You might find Charles Williams's writing on Excel
calculations helpful - see http://www.decisionmodels.com/calcsecrets.htm

Note that
* functions that are both marked with IsMacroType=true and contain an
AllowReference=true parameter are automatically considered volatile by
Excel.
* marking functions with IsMacroType=true and reading the valus from
the sheet allows you to see the uncalculated values (which is one part
of what you are reporting). You might consider this a feature, and not
a bug.

Regards,
Govert




On May 22, 8:02 pm, Faraz Ahmed Qureshi <farazem...@gmail.com> wrote:
> Thanx for the timely reply ngm. Sure do appreciate the same. However, the
> UDF seems simple because I redesigned the same to only present my problem.
> The actual UDF is quite a lengthy one. The only way I have yet found to
> resolve the same, eventhough temporarily, is by inserting the RANDBETWEEN
> functions (or the precedent data) only after I have inserted the main UDF
> first.
Reply all
Reply to author
Forward
0 new messages