Forum Discussion
Recurring Deposit Calculation VBA Code
PendingInt = 0
For i = 1 To N
Maturity = (Maturity + Monthly)
PendingInt = PendingInt + Maturity * (1 + R / CompoundingFactor)
IF NOT (i MOD CompoundingFactor) THEN
Maturity = Maturity + PendingInt
PendingInt = 0
END IF
Next i
SP_Pandey, note the following corrections....
mtarler wrote: PendingInt = PendingInt + Maturity * (1 + R / CompoundingFactor)
Should be Maturity * R / 12. Interest is calculated monthly.
In SP_Pandey's example, with an annual rate of 12%, the monthly rate is correctly 1% (12% / 12) when compounded quarterly, not 3% (12% / 4).
Aside.... Since that is the only use of R, you might consider calculating R as
R = CDbl(Replace(TextBox16.Value, "%", "")) / 100 / 12
in the first place, and simply using Maturity * R in the loop.
-----
mtarler wrote: IF NOT (i MOD CompoundingFactor) THEN
Should be i MOD (12 / CompoundingFactor).
For example, for semiannual compounding, CompoundingFactor is 2, but interest is compounded every 6 months (12 / 2), not every 2 months.
In fact, with these corrections, I see no purpose in having CompoundingFactor at all.
I would have CompoundingFreq, which is (every) 12, 6, 3, or 1 (months) for annual, semiannual, quarterly or monthly.
Then I would write
If i MOD CompoundingFreq = 0 Then
Aside.... This presumes that N is a multiple of CompoundingFreq. In case it is not, you might want to add the statement
Maturity = Maturity + PendingInt
after Next for the For-loop.
Note that PendingInt = 0 when N is a multiple of CompoundingFreq. So the added statement does not cause any problem normally.
- SP_PandeyDec 15, 2023Copper Contributor
Thank you Joe for your effort. However, the issues are still pertaining. The maturity value for monthly is calculating perfectly and rest is producing wrong value. I hereby sharing you my working file. Could you please resolve it and share it back to me?
https://drive.google.com/file/d/1r9SKZKhNthTTwdUDXmWnWhT6uNtwXGgl/view?usp=sharing
Thank you
- mtarlerDec 14, 2023Silver ContributorAh yes thank you Joe for catching those corrections. I also agree with everything you noted for improvements and apologize to the OP for not catching my errors before posting.