Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Not sure you need the transpose and it is simple to see
from the resulting array what the range input was: Sub test() Dim arr 'row input range arr = Range(Cells(1), Cells(10)) MsgBox UBound(arr), , UBound(arr, 2) 'column input range arr = Range(Cells(1), Cells(10, 1)) MsgBox UBound(arr), , UBound(arr, 2) End Sub RBS "Jonas" wrote in message ups.com... Hello, I'm trying to create a function that will output the present value of a stream of cash flows. I was able to get it to work for a range in a column but I haven't been able to get it to work for a range in a row. I tried to get rid of the transpose in various ways without any luck. Below is the code that works for data in a column. I think that it would also be neat if I could put something in the code to determine if the stream of cash flows are in a column or in a row. I was thinking that if I were able to determine the row using Excel's row function of the beginning cell in the range and the the row of the last cell in the range, I could create some logic to determine if the cashflows are in a row or in a column. ------------------------------------------------------------------------------------------------------------------ Function pval_T(irate_T As Double, rngIn As Range) As Variant Dim myArr As Variant, i As Long myArr = Application.WorksheetFunction.Transpose(rngIn) For i = LBound(myArr) To UBound(myArr) pval_T = pval_T + myArr(i) / (1 + irate_T) ^ i Next i End Function --------------------------------------------------------------------------------------------------------------------- Suggestions are appreciated. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Array problem, I think.. | Excel Worksheet Functions | |||
Array Problem -- again! | Excel Programming | |||
Array problem: Key words-Variant Array, single-element, type mismatch error | Excel Programming | |||
Array problem? | Excel Programming | |||
Array problem: Key words-Variant Array, single-element, type mismatch error | Excel Programming |