Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi everyone,
I have written a small program that calculates daily compounded interest and keep having a problem with an overflow error. My interest rate variables get too big and crash the program. Isn't there a way to limit how big the numbers get??? Please advise... Sub interestcalculation() Dim t As Integer Dim v_startingprinciple As Double Dim v_rounddownmultiple As Double Dim v_actualinterestrate As Single Dim v_dailyinterest As Single Dim v_initialprinint As Double Dim v_accumprinint As Double Dim v_previoustest As Variant Dim v_rate As Single Dim v_remainingdaysinperiod As Double 'NOTES: 'FY2006 = 0.0057 'FY2007 = 0.0107 'FY2008 = 0.0145 'FY2009 = 0.0119 'Manually set variables for execution: v_startingprinciple = 200 v_rate = 0.000057 v_remainingdaysinperiod = 26 v_rounddownmultiple = (Application.WorksheetFunction.RoundDown(v_startin gprinciple, -2) / 100) v_actualinterestrate = v_rounddownmultiple * v_rate v_dailyinterest = v_startingprinciple * v_actualinterestrate v_initialprinint = v_startingprinciple + v_dailyinterest v_accumprinint = 0 For t = 2 To v_remainingdaysinperiod v_rounddownmultiple = (Application.WorksheetFunction.RoundDown(v_initial prinint, -2) / 100) v_actualinterestrate = v_rounddownmultiple * v_rate v_dailyinterest = v_initialprinint * v_actualinterestrate v_initialprinint = v_initialprinint + v_dailyinterest Next t 'select the cell you'd like to output the number in BEFORE you run the analysis! ActiveCell.Value = v_initialprinint End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Overflow | Excel Programming | |||
Overflow | Excel Programming | |||
Overflow when translating from C++ HELP!! | Excel Programming | |||
VBA overflow | Excel Programming | |||
VBA overflow | Excel Programming |