Hey guys, I've been struggling with a function that I'm writing to compute the payback period.
The payback period is the amount of years it takes you to recover an investment or to pay back a loan. If the first year I invest 100 bucks and the next two years I get back 50 and 100, the payback period will be 1.5 years.
This year I get -100 (I pay 100) -100 in profit
Year 1 I get 50 -50 in profit
Year 2 I get 100 50 in profit
Therefore, it took me one year and the first half of the 2nd one (50 $ remaining / 100$ I get).
My code is this:
I want it to check if carry + cvec(i) is greater/equal to 0. If it is I want the payback value to equal the next statement and then leave the function. If it's not, I want it to go to the next "i" and try again.
For some reason, I get #value error in the cell where I input the formula.
Thank you so much in advance.
Bookmarks