Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

using range in function (macro)

I would like to pass a range in a function and use that in a macro but cannot figure out how to do it.

I tried to create a formula in a cell like: =TEST(A2:A6)

and then a routine like:

Public Function Test(r as com.sun.star.table.CellRange) as String
cnt = 0
oEnum = r.createEnumeration()
Do while oEnum.hasMoreElements()
    cnt = cnt + 1
    oEnum.nextElement()
Loop
    Test = ">> " & cnt & " " & typename(r) & " " & isObject(r) & " " &  IsNull(r) & " " & ThisComponent.Sheets(0).getCellRangeByName("A2:A4").computeFunction(com.sun.star.sheet.GeneralFunction.COUNT)
End Function

but no matter what I try I get errors or strange behaviour. Anyone knows how to do this?

thx a lot.

click to hide/show revision 2
No.2 Revision

using How can I use a cell range in function (macro)a macro function?

I would like to pass a range in a function and use that in a macro but cannot figure out how to do it.

I tried to create a formula in a cell like: =TEST(A2:A6)

and then a routine like:

Public Function Test(r as com.sun.star.table.CellRange) as String
cnt = 0
oEnum = r.createEnumeration()
Do while oEnum.hasMoreElements()
    cnt = cnt + 1
    oEnum.nextElement()
Loop
    Test = ">> " & cnt & " " & typename(r) & " " & isObject(r) & " " &  IsNull(r) & " " & ThisComponent.Sheets(0).getCellRangeByName("A2:A4").computeFunction(com.sun.star.sheet.GeneralFunction.COUNT)
End Function

but no matter what I try I get errors or strange behaviour. Anyone knows how to do this?

thx a lot.