Hello I need some help to create a VBA code to ;
· User enter a End Value
· User enter monthly amount
· User enters rate (Currently this is hard coded but ideally user should enter it)
· Start date
I need to calculate interest every June and Dec interest the add the interest to current balance
When Cur balance is = stop or as soon as it it > than stop any interest calc and store value
Example below
Stop Value 1200
Stop Value 1000
This is my code thus far
Private Sub CommandButton1_Click()
Dim Avg As Long
Dim Count As Long
Dim i As Integer
Dim Total As Long
Dim mth As Long
Dim stp As Long
Dim curbal As Long
Dim monthly As Long
i = 2
Count = 0
monthly = Cells(1, 2).Value
stp = Cells(1, 1).Value
curbal = Cells(i, 1).Value
Count = 0
Do Until Count = 6 Or Running > stp
Count = Count + 1
mth = monthly + mth
MsgBox mth
Total = Total + (monthly * Count)
Loop
Running = mth + curbal
Avg = (((Total / 6) * 0.025) / 12) * 6 + Running
Cells(i, 2).Value = Avg
Cells(i, 3).Value = Count
MsgBox Avg
End Sub
I also tried using If statements but no luck I can also post that code.
EDIT:
Stop 1000
https://1drv.ms/u/s!Ahv8cig51I35hGR1XkcmwCley2qx
Stop 1200
https://1drv.ms/u/s!Ahv8cig51I35hGKQc18a-R4Ml8ZX
· User enter a End Value
· User enter monthly amount
· User enters rate (Currently this is hard coded but ideally user should enter it)
· Start date
I need to calculate interest every June and Dec interest the add the interest to current balance
When Cur balance is = stop or as soon as it it > than stop any interest calc and store value
Example below
Stop Value 1200
Stop Value 1000
This is my code thus far
Private Sub CommandButton1_Click()
Dim Avg As Long
Dim Count As Long
Dim i As Integer
Dim Total As Long
Dim mth As Long
Dim stp As Long
Dim curbal As Long
Dim monthly As Long
i = 2
Count = 0
monthly = Cells(1, 2).Value
stp = Cells(1, 1).Value
curbal = Cells(i, 1).Value
Count = 0
Do Until Count = 6 Or Running > stp
Count = Count + 1
mth = monthly + mth
MsgBox mth
Total = Total + (monthly * Count)
Loop
Running = mth + curbal
Avg = (((Total / 6) * 0.025) / 12) * 6 + Running
Cells(i, 2).Value = Avg
Cells(i, 3).Value = Count
MsgBox Avg
End Sub
I also tried using If statements but no luck I can also post that code.
EDIT:
Stop 1000
https://1drv.ms/u/s!Ahv8cig51I35hGR1XkcmwCley2qx
Stop 1200
https://1drv.ms/u/s!Ahv8cig51I35hGKQc18a-R4Ml8ZX
Last edited by a moderator: