No need for VBA or for looping. An excel formula can achieve what you want.
=NPV(-0.9,,IFERROR(MID(A1,1+LEN(A1)-ROW(OFFSET(A$1,,,LEN(A1))),1)%,""))
This is an array formula. You have to press Ctrl + Shift + Enter
Explanation:
Each term is multiplied by the inverse of (1+rate)^n
, where n
is the nth
term in the series.
By using different values for rate, we can get different results. In this case, using -0.9
gives us 1 + rate = 1 + -0.9 = 0.1
.
Result: {0.1;0.01;0.001;0.0001;0.00001}
Inverse of above: {10;100;1000;10000;100000}
Also NPV skips text values which contributes to the above
Disclaimer: I did not come up with this formula. I had seen this formula long time ago and simply fell in love with it. Since then it has been a part of my databank.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…