Forum Discussion
Recurring Deposit Calculation VBA Code
SP_Pandey The problem is that you are still compounding monthly in each case. Here is my suggestion to try:
' Calculate maturity value based on selected option button
If OptionButton1.Value Then ' Monthly mode
R= 1 + R / 12 ' calculate new rate based on compounding frequency
N= N \ 1 ' calculates the number of updates to be done base on frequency
REMAININGPAYMENT = 0 ' calculates any additional payment when frequency has left over
MONTHLY = MONTHLY * 1 ' calculates the sum of payments for the frequency of interest
ElseIf OptionButton2.Value Then ' Quarterly mode
R= 1 + R / 4
N= N \ 3
REMAININGPAYMENT = (N MOD 3) * MONTHLY
MONTHLY = MONTHLY * 3
ElseIf OptionButton3.Value Then ' Half-Yearly mode
R= 1 + R / 2
N= N \ 6
REMAININGPAYMENT = (N MOD 6) * MONTHLY
MONTHLY = MONTHLY * 6
ElseIf OptionButton5.Value Then ' Yearly mode
R= 1 + R / 1
N= N \ 12
REMAININGPAYMENT = (N MOD 3) * MONTHLY
MONTHLY = MONTHLY * 12
End If
Maturity = 0 ' Initial maturity value
' Calculate maturity value using the appropriate compounding formula
For i = 1 To N
Maturity = (Maturity + Monthly) * R
Next i
Maturity = Maturity + REMAININGPAYMENT