It seems like if you return an n-by-n array from a User Defined Function used within an array formula, Calc nicely places each element of the returned array into a different cell as expected.
If there are more return elements than cells in the array formula range, then results are truncated as expected. If there are fewer return elements than cells in the array formula range, then #N/A is entered into each cell of the array formula range that does not have a matching element in the returned array, as expected (although not pretty). However, it seems like if a 1-by-n array is returned from the UDF, then that row of elements is repeated throughout the height of the array formula range, just as if a simple scalar had been returned. Other than to pad, say, an empty row under the single-row, is there a nice way to prevent this behavior, so that a single-element result just occupies the first row of the array formula range, rather than getting repeated throughout the entire range?Example:
Function MyFunc(Value As String)
Dim Result(1 To 1, 1 To 1)
Result(1,1) = Value
MyFunc = Result
End Function
If we enter MyFunc(“Hello”) as an array formula in A1 through A4 we get the result
Hello
Hello
Hello
Hello
However, if we had
Function MyFunc(Value As String)
Dim Result(1 To 2, 1 To 1)
Result(1,1) = Value
Result(2,1) = "--End--"
MyFunc = Result
End Function
we just get
Hello
–End–
<Empty>
<Empty>
I’m looking for the follow result with the first version of MyFunc:
Hello
<Empty>
<Empty>
<Empty>