Forum Discussion
Recurring Deposit Calculation VBA Code
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.