Skip to main content

NPV

Returns the net present value of an investment based on a discount rate and a series of future payments (negative values) and income (positive values).

Syntax

expression.NPV(arg1, args);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters

NameRequired/OptionalData typeDefaultDescription
arg1RequiredApiRange | ApiName | numberThe discount rate.
argsRequirednumber | ApiRange | number[]Up to 255 arguments representing future payments (negative values) and income (positive values). The first argument is required, the subsequent values are optional. Arguments can be numbers, ranges, arrays of numbers.

Returns

number

Example

Calculate the net present value of an investment using a discount rate in a spreadsheet.

// How do I find the net present value of future cash flows in a spreadsheet?

// Evaluate an investment by discounting future payments and income in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue("Rate");
worksheet.GetRange("A2").SetValue(0.05);
let values = ["Payment", -10000, 3000, 4500, 6000];

for (let i = 0; i < values.length; i++) {
worksheet.GetRange("B" + (i + 1)).SetValue(values[i]);
}
let range = worksheet.GetRange("B2:B5");
worksheet.GetRange("B6").SetValue(func.NPV(0.05, range));