Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Order of Calculation for Functions in Automation Add-In

I have written an Automation Add-In in C# (2005). On my spreadhseet, I
have the result of one volatile function as one of the input params for
another volatile function (i.e. MyFunc1 is in cell B2, and B2 is an
input param to MyFunc2). The behavior I have noticed is that when I hit
F9, The 2nd Function (MyFunc2) tries to execute first and fails since
the 1st function (MyFunc1) has not yet been calced and only then does
Excel calc the 1st function followed by the 2nd function giving the
correct result. This is dissapointing since Excel knows that one is fed
to the other and should know to calc that one first. The consequence is
that Excel makes an expensive call into the Add-In. It begins to
evaluate the second function and only when it hits a line of code in C#
which tests if the input is valid does it throw a .NET exception which
is expensive. Is there some way to teach Excel the priority, or to
force it to be smarter?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Order of Calculation for Functions in Automation Add-In

Hi Matthew,

solution Part 1: dont make your functions volatile since this is very
inefficient: instead make sure ALL the input for the function is contained
in the argument list. This will also help but not cure the execution
sequence problem.

solution part 2: check that the arguments for the function have been
calculated before executing the function: because of the way that the excel
calculation algorithm works, there is no way of preventing a function being
sometimes executed (possibly more than once) with uncalculated arguments.
(use ISEMPTY() : see http://www.decisionModels.com/calcsecretsj.htm)

solution part 3: I have been told that c# automation addins execute more
slowly than any other addin type: consider using another technology (I have
not personally verified this statement)

Charles
______________________
Decision Models
FastExcel 2.2 Beta now available
www.DecisionModels.com

"Matthew Wieder" wrote in message
...
I have written an Automation Add-In in C# (2005). On my spreadhseet, I
have the result of one volatile function as one of the input params for
another volatile function (i.e. MyFunc1 is in cell B2, and B2 is an input
param to MyFunc2). The behavior I have noticed is that when I hit F9, The
2nd Function (MyFunc2) tries to execute first and fails since the 1st
function (MyFunc1) has not yet been calced and only then does Excel calc
the 1st function followed by the 2nd function giving the correct result.
This is dissapointing since Excel knows that one is fed to the other and
should know to calc that one first. The consequence is that Excel makes an
expensive call into the Add-In. It begins to evaluate the second function
and only when it hits a line of code in C# which tests if the input is
valid does it throw a .NET exception which is expensive. Is there some way
to teach Excel the priority, or to force it to be smarter?



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
automation of YTD calculation MPP Excel Worksheet Functions 2 November 20th 08 02:15 PM
Forcing calculation through automation Nirmal Singh[_2_] Excel Programming 2 May 15th 06 10:30 AM
Tab Order Automation?? peter.thompson[_22_] Excel Programming 3 January 2nd 06 09:25 PM
addIn functions in automation nicgendron Excel Programming 1 July 14th 05 10:35 AM
Add-In Functions not listed in Automation mrvgson Excel Programming 11 January 8th 05 05:27 AM


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