+ Reply to Thread
Results 1 to 9 of 9

VBA Code for NPV Function with Variable interest rate

  1. #1
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Hong Kong
    MS-Off Ver
    Office 365 PC Version
    Posts
    216

    VBA Code for NPV Function with Variable interest rate

    Dear all,

    I would like a function which works like the NPV function except that the interest rate should be variable and a range rather than a single number.

    Is it possible to see the code for the excel NPV function so that I can modify it?

    Or alternatively has anyone seen such a function?

    Lastly, any insights on how to create such a function would be much appreciated.

    Regards John

  2. #2
    Forum Contributor
    Join Date
    11-05-2013
    Location
    Germany
    MS-Off Ver
    Excel 2013
    Posts
    120

    Re: VBA Code for NPV Function with Variable interest rate

    I don't understand how the interest rate can be a range. You can discount cash flows (cf) with 1 discount rate. Or do you want to discount cf's each with another interest rate?

    Maybe show a short calculation example and how you want it to work.
    Say thanks, Click *

  3. #3
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: VBA Code for NPV Function with Variable interest rate

    does the explanation (including formula) that is foind by following the "help on function" hyperlink not help you?

    not sure what your expectations are from a "range" of interest rates are, I have always used it as a single rate

    Cheers

    Jmac1947

    1. Please consider clicking on the * Add Reputation if you think this post has helped you
    2. Mark your thread as SOLVED when question is resolved

  4. #4
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Hong Kong
    MS-Off Ver
    Office 365 PC Version
    Posts
    216

    Re: VBA Code for NPV Function with Variable interest rate

    Hi I have enclosed an example.

    Your help is appreciated.

    Thanks John
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    11-05-2013
    Location
    Germany
    MS-Off Ver
    Excel 2013
    Posts
    120

    Re: VBA Code for NPV Function with Variable interest rate

    First chooese the range of the interest rates and then of the cashflows.


    All Credit goes to Izandol! -> http://www.excelforum.com/excel-prog...ml#post3569799



    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Hong Kong
    MS-Off Ver
    Office 365 PC Version
    Posts
    216

    Re: VBA Code for NPV Function with Variable interest rate

    Hi Decar,

    Thanks for the above information, I will test it out.

    Regards John

  7. #7
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Hong Kong
    MS-Off Ver
    Office 365 PC Version
    Posts
    216

    Re: VBA Code for NPV Function with Variable interest rate

    Hi,

    That works great...amazing !

    I need to expand my formula.

    In fact have 5 yield curves.

    My cash flows are by year.

    A column in the spreadsheet provides me with year.

    So for year 1 I want to use yield curve 1, for year 2 I want to use yield curve 2, ....for year 5+ I want to use yield curve 5.

    I modified the formula but am having an error and have questions as follows:

    1) year as range, this is a cell do I need to use Year as cell instead?

    2) the if statement is not compiling do I need to use VBA code r can i use excel functions?

    Any help is appreciated, thanks JV


    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    11-05-2013
    Location
    Germany
    MS-Off Ver
    Excel 2013
    Posts
    120

    Re: VBA Code for NPV Function with Variable interest rate

    hmm. Maybe make another excel sheet so I understand better what you want.

    As far as I understand it you could just expand the interest and cash flows columns for the years your investment is, or whatever you calculate, and plug in the interest rates and for 5+ years just double click on the site.

    The problem with building the formula you described it it would only work for that calculation. If your next investment has 8 years varying yield curves you cant use it anymore.

  9. #9
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Hong Kong
    MS-Off Ver
    Office 365 PC Version
    Posts
    216

    Re: VBA Code for NPV Function with Variable interest rate

    Hi Decar,

    Enclosed an example.

    I did it 3 ways including:

    1) Helper columns
    2) Array formula
    3) Your formula modified.

    Actually I think i am good to go.

    Thanks for your help, JV
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 02-12-2012, 12:45 AM
  2. Need Help By Tuesday -VARIABLE INTEREST RATE HELP HELP HELP
    By maltass in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 08-23-2007, 04:13 AM
  3. variable interest rate calculation
    By Mac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-09-2005, 09:05 PM
  4. Replies: 0
    Last Post: 09-12-2005, 11:05 PM
  5. [SOLVED] calculate interest on an increasing balance with variable rate
    By LPMastro in forum Excel General
    Replies: 0
    Last Post: 02-16-2005, 04:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1