James E. Lang wrote:
I am using OOo 2.1.
I can't figure out how to invoke a sub from within a formula. As an example, I
created the following sub:
sub Hypot(a as Long, b as Long)
Hypot = a * a + b * b
end sub
I then tried this formula in one of the cells:
=Hypot(3;4)
I expected to generate the value 25 but instead I got #NAME?
Do I misunderstand what the Star Basic subroutines are supposed to do? If not
then what steps are needed to make this example work? Obviously, this is a very
simplistic example since I could just as easily entered =3*3+4*4 into the cell.
The thing is that I want to code the following in more than 80 cells
=if(or(cond1(n);and(not(cond2(n);cond5(n));and(cond2(n);not(cond3(n));cond4(n)))
;"";dat[n))
In this formula, cond1(), cond2(), cond3(), cond4(), cond5(), and dat() are all
moderately complex in structure.
First, you need a Function, NOT a Sub:
Function Hypot (etc) as Long
(etc)
End Function
Secondly, the function needs to be in a library of a document where you
are using it. If you want to use it in several documents, it should be
in the "My Macros" Standard library.
--
Direct mail to teaman is not opened; if necessary, email realmail
Xfce on PCLinuxOS, OOo 2.0.2 (en_GB) www.revivalcentres.org
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]