Difference between revisions of "Documentation/How Tos/Calc: CURRENT function"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Initial content)
 
m
Line 16: Line 16:
  
 
<tt>'''A2 + B2 + STYLE(IF(CURRENT()>10; ”Red”; ”Default”))'''</tt>
 
<tt>'''A2 + B2 + STYLE(IF(CURRENT()>10; ”Red”; ”Default”))'''</tt>
: returns <tt>'''A2 + B2'''</tt> (note that <tt>'''STYLE'''</tt> always returns <tt>'''0'''</tt>). If this sum is greater than <tt>'''10'''</tt>, the style <tt>'''Red'''</tt> is applied to the cell. See the <tt>'''STYLE'''</tt> function for more explanation.
+
: returns <tt>'''A2 + B2'''</tt> &nbsp;&nbsp;(<tt>'''STYLE'''</tt> returns <tt>'''0'''</tt> here). If this sum is greater than <tt>'''10'''</tt>, the style <tt>'''Red'''</tt> is applied to the cell. See the <tt>'''STYLE'''</tt> function for more explanation.
  
 
<tt>'''"choo" & CURRENT()'''</tt>
 
<tt>'''"choo" & CURRENT()'''</tt>

Revision as of 07:38, 8 December 2007


CURRENT

Returns the current (to date) result of evaluating the formula.


Syntax:

CURRENT()

This function returns the result to date of evaluating the formula of which it is a part (in other words the result as far as that evaluation has got). Its main use is together with the STYLE function to apply selected styles to a cell depending on the cell contents.


Example:

1 + 2 + CURRENT()

returns 6. The formula is calculated from left to right as: 1 + 2 equals 3, giving the result to date when CURRENT() is encountered; CURRENT() therefore yields 3, which is added to the original 3 to give 6.

A2 + B2 + STYLE(IF(CURRENT()>10; ”Red”; ”Default”))

returns A2 + B2   (STYLE returns 0 here). If this sum is greater than 10, the style Red is applied to the cell. See the STYLE function for more explanation.

"choo" & CURRENT()

returns choochoo.


Further Information:

This function is best used only in simple situations. A more complex example: 1 + 2*CURRENT() returns 5, because although the 1 has been encountered as the formula is evaluated, it is ignored while the more important multiplication is performed. Thus CURRENT() in this case yields 2, hence the result: 1 + 2*2 equals 5. However the exact order of calculation in more complex cases should not be relied on.


See also:

STYLE

Information functions

Personal tools