NPV Function [VBA]

Calculates the Net Present Value of an investment, based on a supplied discount rate, and a series of deposits and withdrawals.

警告图标

该功能或常量可通过以下语句启用:Option VBASupport 1,该语句需要放置在模块的每个可执行程序代码的前面。


语法:

NPV (Rate as Double, Values() as Double)

返回值:

Double

参数:

Rate is the discount rate for a period.

Values() is an array that represent deposits (positive values) or withdrawals (negative values).

错误代码:

5 无效的过程调用

示例:

REM ***** BASIC *****

Option VBASupport 1

Sub ExampleNPV

 Dim r As Double

 Dim pValues(5) as Double

 pValues(0) = 100

 pValues(1) = 100

 pValues(2) = 100

 pValues(3) = -300

 pValues(4) = 100

 pValues(5) = 100

 r = 0.06

 p = NPV( r, pValues)

 Print p ' returns 174,894967305331

End Sub