NPV Function [VBA]

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

Ikona ostrzeżenia

Ta funkcja lub stała jest włączona za pomocą instrukcji Opcja VBASupport 1 umieszczona przed kodem programu wykonywalnego w module.


Składnia:

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

Zwracana wartość:

Double

Parametry:

Rate is the discount rate for a period.

Values()jest tablicą reprezentującą depozyty (wartości dodatnie) lub wypłaty (wartości ujemne).

Kody błędów:

5 Nieprawidłowe wywołanie procedury

Przykład:

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 ' zwraca 174,894967305331

End Sub