Article ID: 126806
Article Last Modified on 8/19/2003
Application.Sum(Range("A1:T100"))
is actually two calls; one to construct a range, and one to call the Sum
function. Internally, the Sum function adds up the cell contents
directly without allocating memory. By contrast, the following call to a
function in a DLL
MyDllBasedSum(Range("A1:T100"))
is one IDispatch call, and one DLL call (faster). However, within the
DLL call, there is at least one IDispatch call to fetch the contents of
the range as an array, an operation that allocates a lot of memory and
performs a lot of type conversion and copying (much slower), only to
have it all immediately freed once the sum is taken.
Application.Sum(5, 6)
calculates slower than a Visual Basic expression of 5 + 6. Note that
there is not a lot of overlap between these functions because the
Microsoft Excel worksheet functions that overlapped with Visual Basic
runtime functions were intentionally not made accessible from Visual
Basic.Additional query words: XL
Keywords: KB126806