How can I use a cell range in a macro function? [closed]

asked 2013-02-20 00:15:23 +0200

startu gravatar image

updated 2014-07-25 23:15:21 +0200

bencomp gravatar image

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.

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by bencomp
close date 2014-07-25 23:15:51.643873

Comments

May be so?

JohnSUN gravatar imageJohnSUN ( 2013-02-20 11:16:46 +0200 )edit

HI @startu -- Still looking for an answer here?

qubit gravatar imagequbit ( 2013-04-30 07:28:27 +0200 )edit

It looks like @JohnSUN pointed at a earlier similar question that was answered: http://ask.libreoffice.org/en/questio... This is a duplicate unless otherwise decided later.

bencomp gravatar imagebencomp ( 2014-07-25 23:17:22 +0200 )edit