1*cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2*cdf0e10cSrcweir<helpdocument version="1.0"> 3*cdf0e10cSrcweir 4*cdf0e10cSrcweir<!-- 5*cdf0e10cSrcweir*********************************************************************** 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 12*cdf0e10cSrcweir * 13*cdf0e10cSrcweir * This file is part of OpenOffice.org. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 16*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 17*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 18*cdf0e10cSrcweir * 19*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 20*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 21*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 23*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 24*cdf0e10cSrcweir * 25*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 26*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 27*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 28*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 29*cdf0e10cSrcweir * 30*cdf0e10cSrcweir ************************************************************************ 31*cdf0e10cSrcweir --> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir<meta> 35*cdf0e10cSrcweir <topic id="textscalcguidecellstyle_by_formulaxml" indexer="include" status="PUBLISH"> 36*cdf0e10cSrcweir <title xml-lang="en-US" id="tit">Assigning Formats by Formula</title> 37*cdf0e10cSrcweir <filename>/text/scalc/guide/cellstyle_by_formula.xhp</filename> 38*cdf0e10cSrcweir </topic> 39*cdf0e10cSrcweir </meta> 40*cdf0e10cSrcweir <body> 41*cdf0e10cSrcweir<bookmark xml-lang="en-US" branch="index" id="bm_id3145673"><bookmark_value>formats; assigning by formulas</bookmark_value> 42*cdf0e10cSrcweir <bookmark_value>cell formats; assigning by formulas</bookmark_value> 43*cdf0e10cSrcweir <bookmark_value>STYLE function example</bookmark_value> 44*cdf0e10cSrcweir <bookmark_value>cell styles;assigning by formulas</bookmark_value> 45*cdf0e10cSrcweir <bookmark_value>formulas;assigning cell formats</bookmark_value> 46*cdf0e10cSrcweir</bookmark><comment>mw deleted "applying;"</comment> 47*cdf0e10cSrcweir<paragraph xml-lang="en-US" id="hd_id3145673" role="heading" level="1" l10n="U" 48*cdf0e10cSrcweir oldref="13"><variable id="cellstyle_by_formula"><link href="text/scalc/guide/cellstyle_by_formula.xhp" name="Assigning Formats by Formula">Assigning Formats by Formula</link> 49*cdf0e10cSrcweir</variable></paragraph> 50*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3150275" role="paragraph" l10n="CHG" oldref="14">The STYLE() function can be added to an existing formula in a cell. For example, together with the CURRENT function, you can color a cell depending on its value. The formula =...+STYLE(IF(CURRENT()>3; "Red"; "Green")) applies the cell style "Red" to cells if the value is greater than 3, otherwise the cell style "Green" is applied.</paragraph> 51*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3151385" role="paragraph" l10n="U" oldref="15">If you would like to apply a formula to all cells in a selected area, you can use the<emph/> 52*cdf0e10cSrcweir <item type="menuitem">Find & Replace</item> dialog.</paragraph> 53*cdf0e10cSrcweir <list type="ordered"> 54*cdf0e10cSrcweir <listitem> 55*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3149456" role="listitem" l10n="U" oldref="16">Select all the desired cells.</paragraph> 56*cdf0e10cSrcweir </listitem> 57*cdf0e10cSrcweir <listitem> 58*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3148797" role="listitem" l10n="U" oldref="17">Select the menu command <emph>Edit - Find & Replace</emph>.</paragraph> 59*cdf0e10cSrcweir </listitem> 60*cdf0e10cSrcweir <listitem> 61*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3150767" role="listitem" l10n="U" oldref="18">For the <item type="menuitem">Search for</item> term, enter: .<item type="literal">*</item> 62*cdf0e10cSrcweir </paragraph> 63*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3153770" role="listitem" l10n="U" oldref="19">".*" is a regular expression that designates the contents of the current cell.</paragraph> 64*cdf0e10cSrcweir </listitem> 65*cdf0e10cSrcweir <listitem> 66*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3153143" role="listitem" l10n="U" oldref="20">Enter the following formula in the <item type="menuitem">Replace with</item> field: <item type="literal">=&+STYLE(IF(CURRENT()>3;"Red";"Green"))</item> 67*cdf0e10cSrcweir </paragraph> 68*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3146975" role="listitem" l10n="U" oldref="21">The "&" symbol designates the current contents of the <emph>Search for</emph> field. The line must begin with an equal sign, since it is a formula. It is assumed that the cell styles "Red" and "Green" already exist.</paragraph> 69*cdf0e10cSrcweir </listitem> 70*cdf0e10cSrcweir <listitem> 71*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3149262" role="listitem" l10n="U" oldref="22">Mark the fields <link href="text/shared/01/02100000.xhp" name="Regular expressions"><emph>Regular expressions</emph></link> and <emph>Current selection only</emph>. Click <emph>Find All</emph>.</paragraph> 72*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3144767" role="listitem" l10n="U" oldref="24">All cells with contents that were included in the selection are now highlighted.</paragraph> 73*cdf0e10cSrcweir </listitem> 74*cdf0e10cSrcweir <listitem> 75*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3147127" role="listitem" l10n="U" oldref="23">Click<emph/> 76*cdf0e10cSrcweir <item type="menuitem">Replace all</item>.</paragraph> 77*cdf0e10cSrcweir </listitem> 78*cdf0e10cSrcweir </list> 79*cdf0e10cSrcweir <section id="relatedtopics"> 80*cdf0e10cSrcweir <embed href="text/scalc/guide/cellstyle_conditional.xhp#cellstyle_conditional"/> 81*cdf0e10cSrcweir <embed href="text/scalc/guide/cellstyle_minusvalue.xhp#cellstyle_minusvalue"/> 82*cdf0e10cSrcweir </section> 83*cdf0e10cSrcweir </body> 84*cdf0e10cSrcweir</helpdocument>