Re: VBA Moving Average Calculation
Hi smuzoen,
Thank you for your comprehensive reply ... it's really appreciated! Having now defined everything correctly, I used the following code in addition to what you had provided for me, and it gave me the moving average that I required:
Code
numRowb = Range("MovingAverage").Rows.Count
ReDim SumArray(numRowb) As Double
For y = 0 To numRowb - 1
For x = 0 To 9
SumArray(y) = SumArray(y) + StockPrice(x + y)
Next x
Next y
For i = 1 To numRowb
Range("MovingAverage").Cells(i) = SumArray(i - 1) / 10
Next i
Display More
I was toying with the code that I had provided to you earlier, and was changing a few things here and there. Somehow, I accidentally stumbled on coding that would calculate the response for me. I will definitely rest easy tonight now!
I really can't thank you enough for your help ... I'm terrible with VBA and I'm so relieved to have solved this part of the assignment! Thanks again.