Carthalion Member Licensed User Longtime User Nov 5, 2016 #1 I know that I am not supposed to put code here, but I can't remember where else to put it. It seems that this function should work to find present value, based on a rate, number of payments and monthly payment. Sub Pv(Rate As Double, Nper As Double, Pmt As Double) As Double Return Pmt * Power(Rate + 1, Nper) * Rate / (1 - Power(Rate + 1, Nper)) End Sub When I run this code, I get an answer of 2.01 or so. It should be more like 50,000 PresentValue = Pv(.04/12, 360, -1000) Please tell me where I am messing up, in addition to putting the code in the body of the thread. I will work on code placement...
I know that I am not supposed to put code here, but I can't remember where else to put it. It seems that this function should work to find present value, based on a rate, number of payments and monthly payment. Sub Pv(Rate As Double, Nper As Double, Pmt As Double) As Double Return Pmt * Power(Rate + 1, Nper) * Rate / (1 - Power(Rate + 1, Nper)) End Sub When I run this code, I get an answer of 2.01 or so. It should be more like 50,000 PresentValue = Pv(.04/12, 360, -1000) Please tell me where I am messing up, in addition to putting the code in the body of the thread. I will work on code placement...
M Mahares Expert Licensed User Longtime User Nov 6, 2016 #2 I think your code should be: Code: Copy Sub Pv(Rate As Double, Nper As Double, Pmt As Double) As Double Return Pmt/Rate* (1-Power(1+Rate,-Nper)) End Sub Log("PV: " & Pv(.04/12, 360, 1000) ) 'displays: 209461.24 Upvote 0
I think your code should be: Code: Copy Sub Pv(Rate As Double, Nper As Double, Pmt As Double) As Double Return Pmt/Rate* (1-Power(1+Rate,-Nper)) End Sub Log("PV: " & Pv(.04/12, 360, 1000) ) 'displays: 209461.24
M mberthe Member Licensed User Longtime User Nov 6, 2016 #4 The formula in access is: Pv(Rate,Nper,Pmt,fv,t) where : fv: future value (for a loan fv=0) t =0 if payments at the end of the payments period t =1 if payments at the beginning of the payments period the code is: Code: Copy sub pv(rate as double,nper as double,pmt as double,fv as double,t as int) as double if (t<>0 and t<>1) then return 0 r1= power (1+rate,-nper) return pmt*(1+rate*t)*(1-r1)/rate-fv*r1 end sub if fv=0 and t=0 the result is 209461.24 Upvote 0
The formula in access is: Pv(Rate,Nper,Pmt,fv,t) where : fv: future value (for a loan fv=0) t =0 if payments at the end of the payments period t =1 if payments at the beginning of the payments period the code is: Code: Copy sub pv(rate as double,nper as double,pmt as double,fv as double,t as int) as double if (t<>0 and t<>1) then return 0 r1= power (1+rate,-nper) return pmt*(1+rate*t)*(1-r1)/rate-fv*r1 end sub if fv=0 and t=0 the result is 209461.24