NPV Function [VBA]

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

warning

This constant, function or object is enabled with the statement Option VBASupport 1 placed before the executable program code in a module.


Бинтаксис:


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

Return value:

Double

ΠŸΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹:

Rate is the discount rate for a period.

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

Error codes:

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