Larry X
Serious Developer
Posts: 34
Joined: 2011-04-22
|
function TcoMyAutomationTest1.MySum(var Range: OleVariant): OleVariant;
var
i,j: integer;
ASum: double;
begin
ASum := 0;
for i:=1 to Range.Rows.Count do
for j:=1 to Range.columns.count do
ASum := ASum + Range.Cells[i,j].value;
Result := ASum;
end;
This function is considerably slower than the Excel SUM function. What can I do (if anything) to improve its performance? Thanks. |
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hi Larry,
Sorry but I don't know how exactly the SUM function works so I cannot advise you anything of value.
BTW, you can use native Excel functions in your code. Please see the sample below:
function TADX_UDFSample.MySum(Param1: OleVariant): OleVariant;
begin
Result := Self.COMAddInModule.ExcelApp.WorksheetFunction.Sum(Param1,
EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam);
end;
|
|