Hi Guys,
Looking to create a function which allows you to select a cell and then run a For loop against each cell inside the range from the selected cell to the top of the column.
I.e. if I select cell C5 it will run a for loop against C5, C4, C3, C2, C1 in that order. The formula calculates an expodentially weighted value upto that point in time using a half life of 0.5.
So, if below represent C1:C5:
100
100
100
100
200
It would calculate 200*0.5 + 100 * 0.25 + 100 * 0.125...
Below is my current code:
Cannot get it to work even though debug shows that cell2 is equal to $C$5.
Any suggestions would be great.
Looking to create a function which allows you to select a cell and then run a For loop against each cell inside the range from the selected cell to the top of the column.
I.e. if I select cell C5 it will run a for loop against C5, C4, C3, C2, C1 in that order. The formula calculates an expodentially weighted value upto that point in time using a half life of 0.5.
So, if below represent C1:C5:
100
100
100
100
200
It would calculate 200*0.5 + 100 * 0.25 + 100 * 0.125...
Below is my current code:
Code:
Function HALF_LIFE(cell As Range, half As Double)
Dim i As Long
Dim rng As Range
cell2 = cell.Address
rng = Range(cell2, Range(cell2).End(xlUp)) ' Gets the whole range
NumRows = rng.Rows.Count
For i = NumRows To 1 Step -1
' Formula to calculate weighted amount
Next i
End Function
Cannot get it to work even though debug shows that cell2 is equal to $C$5.
Any suggestions would be great.