I apologize for the length here, but my VBA knowledge is very limited and I want to be clear.
Attempting to shorten and speed Excel VBA Function where one of the calculations sums a series of "N" number absolute differences between a price value ("Y0") and a prior price value ("Y1"). The arithmetic formula looks like this:
Sum( ABS(Y0 - Y1) + ABS(Y1 - Y2) + ABS(Y2 - Y3) + . . . )
or
Sum( ABS(Price - Price.Offset(-1, 0)) + Abs(Price.Offset(-1, 0) + . . . )
Coding the individually referenced price changes is cumbersome and slow. In Excel the following array formula calculates the correct result for one cell in a N = 10 Array:
{ =Sum(Abs($I15:$I24-($I14:$I23))) }
This formula calculates the sum of the absolute differences in the Price series in column I for N = 10 periods. The two ranges in the array are offset by 1 period.
The value from this calculation is the denominator in a ratio used in the Function calculation. I would like VBA to calculate the array sum of absolute differences rather than the arithmetic series.
I have been able to return the addresses for both ranges for N periods in the array, but have not been successful in getting the array calculation of the sum of absolute differences.
It is clear I am not using array calculation properly, if at all. I can get the sum of the arrays but not much beyond and not the sum of the absolute differences as needed. Any help would be greatly appreciated.
'Volatility Formula { =SUM(ABS(Y:Yn)-(Y1:Yn1))) }
RRange = Range(RAddress)
R1Range = Range(R1Address)
R = Application.WorksheetFunction.Sum(Abs(RRange - R1Range))
I would like to calculate the following Excel array Formula and an array in a VBA Function.
{ =SUM(ABS($I15:$I24-($I14:$I23))) }

