The below code (with the SumOffset1 Function) works perfectly and gives the result in the Cell (5,2) correctly. How can I continue the same Loop giving the correct result in the {Cell (5,2) (by using the sum function starts from the cell(3,3)}, then the same Loop giving result in the {Cell (5,3) (by using the sum function starts from the cell(3,4)} and so on: the same Loop giving result in the {Cell (5,k) (by using the sum function starts from the cell(3,k)}.
Sub commulative()
Dim i As Integer
For i = 0 To 5
If Cells(4, 2) <= SumOffset1(i) Then
Cells(5, 2) = (i - 1) * 5 + (Cells(4, 2) - SumOffset1(i - 1)) / (Cells(3, i + 2) / 5)
Exit For
End If
Next i
End Sub
.
Function SumOffset1(iteration As Integer) As Double
Dim sum As Double
Dim j As Integer
For j = 1 To iteration
sum = sum + Cells(3, 2).Offset(0, j)
Next j
SumOffset1 = sum
End Function
What I would like to descripe is the below