Kosior_2607
08-03-2011, 04:57 AM
Hello!
I would like to create correct NPV function in excel (because the one built-in excel do not include cash-flow form period 0).Below I list my objects:
1.Count NPV
2.User selects range (rows are adjacent, each below other in one column)
3.Users inputs interest rate as a number (not percentage, in order to speed up calculation)
4.First row from selection is divided by 0, next (1+i)^ (number of row in selection); i - it is interest rate
I have written the code, but it doesn't work. Could you help me please?
Function MNPV(interest_rate As Double, flow())
Dim i As Integer
MNPV = 0
For i = 0 To UBound(flow)
flow(i) = flow(i) / ((1 + interest_rate / 100) ^ i)
MNPV = MNPV + flow(i)
Next i
End Function
I would like to create correct NPV function in excel (because the one built-in excel do not include cash-flow form period 0).Below I list my objects:
1.Count NPV
2.User selects range (rows are adjacent, each below other in one column)
3.Users inputs interest rate as a number (not percentage, in order to speed up calculation)
4.First row from selection is divided by 0, next (1+i)^ (number of row in selection); i - it is interest rate
I have written the code, but it doesn't work. Could you help me please?
Function MNPV(interest_rate As Double, flow())
Dim i As Integer
MNPV = 0
For i = 0 To UBound(flow)
flow(i) = flow(i) / ((1 + interest_rate / 100) ^ i)
MNPV = MNPV + flow(i)
Next i
End Function