Ask Your Question
0

Current Column Value inside Function

asked 2015-03-06 03:25:09 +0200

OmarLO gravatar image

How can I get an Integer like =column(ref) (ref passed as a parameter) inside of an user-defined Function?

And =column() (the numeric value of the column where I use the function)?

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted
0

answered 2015-03-06 13:26:51 +0200

Lupp gravatar image

updated 2015-03-06 13:39:59 +0200

The parameters of a custom function in Calc are always passed by value if the function was called by the evaluator which is the object in charge of evaluating expressions contained in cells. The function body neither has access to the cells referenced by parameters nor to the cell the function was called from. Only the evaluator will know where to return the result to.

In addition: To get access to Calc functions from custom function code you need to create an access object with the help of the proper uno service first. Read Andrew Pitonyak's book and informations pages. You can get these documents (odt or pdf) from this site.

Calling COLUMN() this way should return the result for the active selection and not for the column the evaluator called the function from. (These may be the same, of course, under specific circumstances.)

edit flag offensive delete link more

Comments

Thaks Lupp. I'll read it

OmarLO gravatar imageOmarLO ( 2015-03-06 17:16:22 +0200 )edit
0

answered 2015-03-06 11:06:55 +0200

OmarLO gravatar image

updated 2015-03-06 11:40:20 +0200

Thanks Karolus, aber =COLUMN() nor =COLUMN( CellReferenz ) doesn't work for me inside a macro Function

EG

Function TMES(Fecha As Date, VV) As String

Dim Ndia As Integer, Nmes As Integer, ddd As String, Nfecha, doif As Integer, ThisC As Integer

doif = COLUMN()- COLUMN(VV)

get an error sub procedure not defined

edit flag offensive delete link more
0

answered 2015-03-06 11:42:07 +0200

pierre-yves samyn gravatar image

Hi - You can pass the column like this: =MYFUNCTION(C1;COLUMN())

Example: ColInFunction.ods

Function MYFUNCTION(Val1, Val2) AS long

MYFUNCTION = Val1 - Val2
End function
edit flag offensive delete link more

Comments

Thanks, Pierre-Yves.

Now it is possible to me to pass column() as parameter in (for example Val2) .

Few years without spreadshets programming was very bad for me. Thanks again

OmarLO gravatar imageOmarLO ( 2015-03-06 17:15:17 +0200 )edit
0

answered 2015-03-06 07:39:50 +0200

karolus gravatar image

Hallo

=COLUMN() without Arguments returns Column-number from Cell with Function.

=COLUMN( CellReferenz ) returns Columnnumber from referenced Cell.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-03-06 03:25:09 +0200

Seen: 582 times

Last updated: Mar 06 '15