+ Reply to Thread
Results 1 to 4 of 4

Writing a VBA USER DEFINED code for DISCOUNTED PAYBACK METHOD

  1. #1
    Registered User
    Join Date
    07-18-2020
    Location
    United States
    MS-Off Ver
    2016
    Posts
    2

    Writing a VBA USER DEFINED code for DISCOUNTED PAYBACK METHOD

    Hi,
    I need to write a UDC for Discounted Payback method. I wrote the code for the payback part of the problem but cannot do the discounted cashflows section. I need to write one code and cannot calculate the discounted CFs in Excel beforehand. Please see problem and info copied below.

    Help please!

    Function Payback(NumFutureCFs, Cost, RangeFutureCFs)

    Dim loopcounter As Integer
    Dim AccumulationCF As Single

    AccumulationCF = Cost

    For loopcounter = 1 To NumFutureCFs
    AccumulationCF = AccumulationCF + RangeFutureCFs(loopcounter)

    If AccumulationCF >= 0 Then Exit For

    Next loopcounter
    Payback = loopcounter - 1 + -(AccumulationCF - RangeFutureCFs(loopcounter)) / RangeFutureCFs(loopcounter)

    Use your user defined function to solve for the discounted payback period on the following project. You want
    to be select the raw cash flows. The function should discount them and determine the discounted
    payback period.

    Year cash flow

    year 0 (10000)
    Year 1 2000
    Year 2 3000
    Year 3 3500
    Year 4 4000
    Year 5 4000

    Discount Rate 9%


    End Function

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Writing a VBA USER DEFINED code for DISCOUNTED PAYBACK METHOD

    Hi, and welcome to the forum.

    I'm going to assume this is a homework task. Nothing is more frustrating than to be working on homework and to get stuck. Without guidance, you might have no hope of finishing the assignment before the deadline. The Internet can be a big help in that respect, but without learning how to get the right answer, asking others to solve your homework questions for you simply becomes a downward spiral (and it's cheating).

    We do not want to contribute to you cheating yourself out of your education, but we also acknowledge that seeking assistance to learn a concept is a legitimate request.

    I'll add the word Homework to your title to clearly indicate you are seeking coaching or tutoring help. Any forum members (who are willing to assist as a tutor) will modify their responses accordingly to facilitate your learning. Tutors don't tell you the answers, they help you figure it out for yourself; so don't expect answers, expect suggestions, or just plain hints.

    Although you are specifically asked to create a UDF nevertheless would you indicate what answer you are expecting so that those who are happy to help can understand the goal.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    07-18-2020
    Location
    United States
    MS-Off Ver
    2016
    Posts
    2

    Re: Writing a VBA USER DEFINED code for DISCOUNTED PAYBACK METHOD

    Hi Richard,

    Yes it is an assignment and would really have preferred to get tutoring on how to do it. I was finally able to do it myself though after trying for the past 36 hours but I thank you. Where on this website would I sign up for tutoring in the future and is it an hourly cost? Is it live tutoring? All information given regarding tutoring would be highly appreciated.

    Thank you again.

    Nova.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Writing a VBA USER DEFINED code for DISCOUNTED PAYBACK METHOD

    Well done for working it out. All we ask is that homework be mentioned in a thread title.

    I doubt there's any necessity to formally 'sign up' for tutoring. Just ask your questions in a normal thread.
    Perhaps indicate you are looking to understand alternative approaches and their relative advantages and disadvantages, and ask for suggestions for optimum and efficient solutions. The way threads proceed can then lead to discussions akin to a tutorial.

+ 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. Userform - VBA code compile error: User-defined type not defined
    By rayhee1985 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-14-2020, 11:03 AM
  2. writing user defined minimum value function
    By kittu_1512 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-27-2015, 12:28 AM
  3. [SOLVED] User form in excel- need help in writing code with if/then statement
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2013, 08:04 AM
  4. Replies: 0
    Last Post: 07-28-2006, 11:20 AM
  5. Writing macro results to user defined areas within excel
    By gauss1976 in forum Excel General
    Replies: 1
    Last Post: 07-27-2006, 08:40 AM
  6. [SOLVED] Discounted Payback
    By Calgarychris in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-25-2006, 04:20 PM
  7. [SOLVED] Discounted Payback
    By Calgarychris in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-24-2006, 01:30 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