(Solved) – User Defined Function – sum with iterative calculation


I am writing a vba code to calculate the interests paid between two periods

I have written this code but it always give me back the value 0.

Function interests_paid_between(rate As Double, firstPer As Integer, lastPer As Integer, NPER As Integer, PV As Double) As Variant

Dim FutureValue As Double
FutureValue = InputBox("What is the future value of the loan? (if it is 0 put 0 else the value)")

    Dim i As Integer

    For i = firstPer To lastPer
        InterestPaid = InterestPaid   IPmt(rate, i, NPER, PV, FutureValue)
    Next i

    interests_paid_between = InterestPaid

End Function

Also, I need to include an option where the future value is no equal to 0.

Could you help me with this?

Leave a Reply

Your email address will not be published. Required fields are marked *