Your problem is that you are offsetting from Dat twice.
Function test3(arg As Integer, dat As Range) As Range
Set test3 = Range(dat.Cells(arg + 1, 1), dat.Cells(arg + 2, 1))
End Function
Returns 2 and 3 when array entered in two cells in the same column.
Dat.Cells(arg+1,1) evaluates to A8
Dat.Cells(arg+2,1) evaluates to A9
so if you do
Dat.Range(A8:A9) this offsets you from A6
Checking from the immediate window to illustrate:
? range("A6:A15").Range("A8").Address
$A$13
? range("A6:A15").Range("A8").value
7
to get what you want, modify it as above.
--
Regards,
Tom Ogilvy
Peter Williams wrote in message
...
Concrete Example
In a clean worksheet insert insert 0 through 9 in cells A6 through A15.
Then select 2 empty cells and enter the formula =test3(2, A6:A15) hit
ctrl+shift+return
I think this should return 2 and 3 in the return cells, it returns 7 and
8.
So it is adding the distance from the start of the array to row 1 to the
offset making it 7 instead of 2. I don't understand why that is
happening.
Pete
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!