Search code examples
scriptingreturn-valuelibreoffice

How to return values in column from StarBasic to Calc


I am trying to move some custom functions from GoogleSheets to LibreOffice Calc.

In GoogleSheets I can return a sequence of values as [1,2,3] to have them on the same row, and as [[1,2,3]] to have them on the same column.

In Libreoffice till now I have been able to return ony a few values in the same row, using the code stub below and pressing Shift+Ctrl+Alt+Enter instead of Enter. But, I can't find the way to get return values to be palced in the same column.

Function mya() as Variant 
    mya = Array(3,2,1)
End Function

Any suggestion ?


Solution

  • For all values in a single column, use the following function with Ctrl+Shift+Enter.

    Function mya() as Variant 
        Dim myarray(2, 0) As Integer
        myarray(0, 0) = 1
        myarray(1, 0) = 2
        myarray(2, 0) = 3
        mya = myarray
    End Function
    

    Documentation is under "Multi-Dimensional Data Fields" at https://wiki.openoffice.org/wiki/Documentation/BASIC_Guide/Arrays.