View Single Post
  #10   Report Post  
david cassain
 
Posts: n/a
Default

On Thu, 26 May 2005 19:56:44 GMT, david cassain

here's my forumla in cell A3:
= MyFunct(A1:D1,A2)


here's the sheet data -- 3 rows, 4 vals in 1st row
---------------------------------
...0.....1.......2......3
...2
...Formula
----------------------------------

here's the trivial test function in module1:

Public Function MyFunct(inArr, inInt)
'~~ test passing range from worksheet to UDF.
Dim i, tmp
For i = LBound(inArr) To UBound(inArr)
tmp = tmp + inArr(i)
Next
MyFunct = tmp / inInt
End Function


here's expected result:
A3 should equal 3 --- (0+1+2+3)/2


I still get the #VALUE! error in the worksheet when I enter my
formula with either [Ctrl]+[Shift]+[Enter] OR [Enter].

dave



working formula -- =MyFunct({0,1,2,3},B2)

non-working formula -- =MyFunct(A1:D1,B2)
It does *not* work when entered as an array formula , or a regular
formula. sigh.

the error excel is giving me is: " a value in the formula is of the
wrong data type" --- so probably "A1:D1" is the wrong formula syntax.

anyone know the proper syntax to convert an excel range --- a vba
array so I can call a UDF?