where,
d_{i} = the i'th payment date
d_{1} = the of 0'th payment date
P_{i} = the ith payment
The Excel XNPV function calculates the Net Present Value for a schedule of cash flows that is not necessarily periodic.
The format of the function is :
Where the arguments are listed in the table below :
rate    The discount rate to apply to the cash flows 
values   
An array of numeric values, representing payments and income, where :  negative values are treated as payments  positive values are treated as income The first payment is optional and denotes a cost or payment at the beginning of the investment 
dates    An array of dates corresponding to the array of payments. This array must be the same length as the supplied values array 
The spreadsheet on the right shows an example of the Xnpv function. The data used is in cells A1B7 of the spreadsheet, with the discounted rate shown in cell B1, the dates of the returns are stored in cells A2A7 and the values of the returns are stored in cells B2B7.
The Xnpv function used to calculate the net present value of the investment with these terms is shown in cell C10.
This function gives the result $4,449.60
More examples of the Excel Xnpv function can be found on the Microsoft Office website
If you get an error from the Excel Xnpv function this is likely to be one of the following :
#NUM!   
Occurs if either:


#VALUE!   
Occurs if either:


#NAME?   
Occurs when Analysis ToolPak addin is not enabled in your Excel. + Show How to Do This in Excel 2003: 