Basic pass a range to function to create

I can’t find how to pass a range to my “MyFirstValue” function.
I’ll give you a very simple example to explain.
In the cell:
“=MyFirstValue(A1:B20)”
In the function:
Function MyFirstValue(rng As Object) As string
oCell = rng.getCellByPosition(0, 0)
MyFirstValue = “MyFirstValue=” & oCell.Value
End Function

When I call the function I get this error message:
BASIC runtime error.
Object variable not set.

You can not pass a range as an Object to a custom function. You can pass the numerical and textual values of the range as a two dimensional array.

Passed range values as an Array.ods (21.5 KB)