Trip wrote:. . .
I currently calculate a moving average of the last x elements stored
within an array. Step one is to find the last element used within the
array, for which I currently use a self-written binary search. Next,
I use a Win32 api to copy the segment of memory (CopyMemory)
containing the elements I want to average into another array so that I
can execute:
Avg = Application.Average(arrayTwo)
The slowest part of this oppoeration is the binary search. . . .
Any ideas??
If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook, you can
get the index number of the last used element with
UBound(arrayOne) - LBound(arrayOne) + 1 - ArrayCountIf(arrayOne)
I have no idea how it compares in speed to your binary search.
Alan Beban