S
sue
Hi all,
I am attempting to write (and I aim to be successful at it) a custom Excel function using VBA. The
function will encapsulate the calculations and error checking necessary to produce the PayBack
period in years for a capital investment. I have been browsing through numerous sources, including
the fine book "Excel 2003 Formulas", but can seem to get it!
What I am having problems with is extracting the values from a range passed as one of the arguments.
The signature is shown below:
Public Function Return_PayBack(CumFlow As Range, NetFlow As Range, period As Integer) As Single
I would like to be able to call the function like:
Return_PayBack(C15:G15,C16:G16, 7)
The last algorithm I tried was:
intCount = 0
For Each f In CumFlow
CFlow(intCount) = f.Value
intCount = intCount + 1
Next f
Return_PayBack = CFlow(0) ' return this value to debug!
The code to produce the PayBack period would be a snap...if I could get the values from the spreadsheet.
Any ideas?
Thanks so much,
Sue
I am attempting to write (and I aim to be successful at it) a custom Excel function using VBA. The
function will encapsulate the calculations and error checking necessary to produce the PayBack
period in years for a capital investment. I have been browsing through numerous sources, including
the fine book "Excel 2003 Formulas", but can seem to get it!
What I am having problems with is extracting the values from a range passed as one of the arguments.
The signature is shown below:
Public Function Return_PayBack(CumFlow As Range, NetFlow As Range, period As Integer) As Single
I would like to be able to call the function like:
Return_PayBack(C15:G15,C16:G16, 7)
The last algorithm I tried was:
intCount = 0
For Each f In CumFlow
CFlow(intCount) = f.Value
intCount = intCount + 1
Next f
Return_PayBack = CFlow(0) ' return this value to debug!
The code to produce the PayBack period would be a snap...if I could get the values from the spreadsheet.
Any ideas?
Thanks so much,
Sue