aqualiary
03-14-2014, 11:42 PM
Hi I'm pretty much a beginner in VBA currently learning it for uni, in one of our homeworks we were asked to use loops to find the average of the returns. I've been stuck on this for a really long time.
This is the code I use
Sub moreloopsave()
For j = 1 To 3
sum_ret = 0
For i = 1 To 6493
sum_ret = sum_ret + Range("B11").Cells(i, j)
Range("G11").Cells(i, 1) = sum_ret / 3
Next i
Next j
End Sub
and this is my results (which does not link to the results obtained with excel) and also I noticed, the results I've gotten with VBA just keeps increasing.
11400
This is the code I use
Sub moreloopsave()
For j = 1 To 3
sum_ret = 0
For i = 1 To 6493
sum_ret = sum_ret + Range("B11").Cells(i, j)
Range("G11").Cells(i, 1) = sum_ret / 3
Next i
Next j
End Sub
and this is my results (which does not link to the results obtained with excel) and also I noticed, the results I've gotten with VBA just keeps increasing.
11400