OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

[Almost solved]Recalculating your own function

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Tiksu
General User
General User


Joined: 31 Dec 2010
Posts: 48

PostPosted: Wed Feb 02, 2011 3:44 am    Post subject: [Almost solved]Recalculating your own function Reply with quote

How could i get my own function recalculated when the values in the source table change?

Let's say that i want to sum the values in col and row positions col1, row1 and col2, row2 and i write a function that does it. Here, i need to use the "basic way" to refer to the cell, ie. integer colNo and integer rowNo.

The result is correct when i type in the function in first time. It is also correct when the source values are changed and i copy paste the function to another cell but the function in the original cell remains unchanged.

The problem is that i cannot tell calc to recalculate the original function in the original cell. If i add some spaces in the function call in the original cell and hit return, the function is recalculated, but that does not seem as an elegant way.

Recalculate ie. F9 does not help.

Tiksu


Last edited by Tiksu on Wed Feb 02, 2011 8:06 am; edited 1 time in total
Back to top
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1453
Location: France

PostPosted: Wed Feb 02, 2011 4:54 am    Post subject: Reply with quote

Hi,
That is normal. You are not following the philosophy of calc functions.
In a Basic function for Calc you should never directly address a cell. Or you will get problems like this one.

A Basic function for Calc should work from its arguments and only return a value (Double or String). An argument may be a cell range, then you get an array of values but not the address of the cell range. A correct Basic function for Calc is independent of the position of the cells.

Another solution to your problem may be a Basic routine run when you need it, by clicking a button for example. The routine then recalculates any cells you want, and even do other things (formatting, message, etc).
_________________
Bernard

OpenOffice.org 1.1.5 fr / Apache OpenOffice 4.0.1 / LibreOffice 4.1.0
MS-Windows 7 Home SP1
This forum is spammed, use instead Apache OpenOffice forums
Back to top
View user's profile Send private message Visit poster's website
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Wed Feb 02, 2011 7:51 am    Post subject: Reply with quote

Try Ctrl+Shift+F9.
Back to top
View user's profile Send private message
Tiksu
General User
General User


Joined: 31 Dec 2010
Posts: 48

PostPosted: Wed Feb 02, 2011 8:13 am    Post subject: Reply with quote

Thank you for the hints!

It seems that

JohnV wrote:
Try Ctrl+Shift+F9.


helps. I get the functions recalculated by pressing Ctrl+Shift+F9. In Basic, could it mean calculateAll.
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Mon Feb 14, 2011 8:59 pm    Post subject: Reply with quote

Note that if you write a Calc function that is called as a calc function, you cannot directly modify any cells on the same sheet used to call the function. Doing otherwise is dangerous and should be expected to fail. it is not clear to me that this is what you mean, however.... Just wanted to mention it.
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group