1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2cdf0e10cSrcweir<helpdocument version="1.0"> 3cdf0e10cSrcweir 4*ce44d6c1SAndrew Rist<!--*********************************************************** 5cdf0e10cSrcweir * 6*ce44d6c1SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 7*ce44d6c1SAndrew Rist * or more contributor license agreements. See the NOTICE file 8*ce44d6c1SAndrew Rist * distributed with this work for additional information 9*ce44d6c1SAndrew Rist * regarding copyright ownership. The ASF licenses this file 10*ce44d6c1SAndrew Rist * to you under the Apache License, Version 2.0 (the 11*ce44d6c1SAndrew Rist * "License"); you may not use this file except in compliance 12*ce44d6c1SAndrew Rist * with the License. You may obtain a copy of the License at 13*ce44d6c1SAndrew Rist * 14*ce44d6c1SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 15*ce44d6c1SAndrew Rist * 16*ce44d6c1SAndrew Rist * Unless required by applicable law or agreed to in writing, 17*ce44d6c1SAndrew Rist * software distributed under the License is distributed on an 18*ce44d6c1SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19*ce44d6c1SAndrew Rist * KIND, either express or implied. See the License for the 20*ce44d6c1SAndrew Rist * specific language governing permissions and limitations 21*ce44d6c1SAndrew Rist * under the License. 22*ce44d6c1SAndrew Rist * 23*ce44d6c1SAndrew Rist ***********************************************************--> 24*ce44d6c1SAndrew Rist 25*ce44d6c1SAndrew Rist 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir<meta> 29cdf0e10cSrcweir <topic id="textscalcguidecellstyle_conditionalxml" indexer="include" status="PUBLISH"> 30cdf0e10cSrcweir <title xml-lang="en-US" id="tit">Applying Conditional Formatting</title> 31cdf0e10cSrcweir <filename>/text/scalc/guide/cellstyle_conditional.xhp</filename> 32cdf0e10cSrcweir </topic> 33cdf0e10cSrcweir </meta> 34cdf0e10cSrcweir <body> 35cdf0e10cSrcweir<bookmark xml-lang="en-US" branch="index" id="bm_id3149263"><bookmark_value>conditional formatting; cells</bookmark_value> 36cdf0e10cSrcweir <bookmark_value>cells; conditional formatting</bookmark_value> 37cdf0e10cSrcweir <bookmark_value>formatting; conditional formatting</bookmark_value> 38cdf0e10cSrcweir <bookmark_value>styles;conditional styles</bookmark_value> 39cdf0e10cSrcweir <bookmark_value>cell formats; conditional</bookmark_value> 40cdf0e10cSrcweir <bookmark_value>random numbers;examples</bookmark_value> 41cdf0e10cSrcweir <bookmark_value>cell styles; copying</bookmark_value> 42cdf0e10cSrcweir <bookmark_value>copying; cell styles</bookmark_value> 43cdf0e10cSrcweir <bookmark_value>tables; copying cell styles</bookmark_value> 44cdf0e10cSrcweir</bookmark><comment>mw deleted "formats;"</comment> 45cdf0e10cSrcweir<paragraph xml-lang="en-US" id="hd_id3149263" role="heading" level="1" l10n="U" 46cdf0e10cSrcweir oldref="24"><variable id="cellstyle_conditional"><link href="text/scalc/guide/cellstyle_conditional.xhp" name="Applying Conditional Formatting">Applying Conditional Formatting</link> 47cdf0e10cSrcweir</variable></paragraph> 48cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3159156" role="paragraph" l10n="U" oldref="25">Using the menu command <emph>Format - Conditional formatting</emph>, the dialog allows you to define up to three conditions per cell, which must be met in order for the selected cells to have a particular format.</paragraph> 49cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id8039796" role="warning" l10n="NEW">To apply conditional formatting, AutoCalculate must be enabled. Choose <emph>Tools - Cell Contents - AutoCalculate</emph> (you see a check mark next to the command when AutoCalculate is enabled).</paragraph> 50cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3154944" role="paragraph" l10n="U" oldref="26">With conditional formatting, you can, for example, highlight the totals that exceed the average value of all totals. If the totals change, the formatting changes correspondingly, without having to apply other styles manually.</paragraph> 51cdf0e10cSrcweir <paragraph xml-lang="en-US" id="hd_id4480727" role="heading" level="2" l10n="NEW">To Define the Conditions</paragraph> 52cdf0e10cSrcweir <list type="ordered"> 53cdf0e10cSrcweir <listitem> 54cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3154490" role="listitem" l10n="U" oldref="27">Select the cells to which you want to apply a conditional style.</paragraph> 55cdf0e10cSrcweir </listitem> 56cdf0e10cSrcweir <listitem> 57cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3155603" role="listitem" l10n="U" oldref="28">Choose <emph>Format - Conditional Formatting</emph>.</paragraph> 58cdf0e10cSrcweir </listitem> 59cdf0e10cSrcweir <listitem> 60cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3146969" role="listitem" l10n="U" oldref="29">Enter the condition(s) into the dialog box. The dialog is described in detail in <link href="text/scalc/01/05120000.xhp" name="$[officename] Help">$[officename] Help</link>, and an example is provided below:</paragraph> 61cdf0e10cSrcweir </listitem> 62cdf0e10cSrcweir </list> 63cdf0e10cSrcweir <paragraph xml-lang="en-US" id="hd_id3155766" role="heading" level="2" l10n="U" 64cdf0e10cSrcweir oldref="38">Example of Conditional Formatting: Highlighting Totals Above/Under the Average Value</paragraph> 65cdf0e10cSrcweir <paragraph xml-lang="en-US" id="hd_id4341868" role="heading" level="3" l10n="NEW">Step1: Generate Number Values</paragraph> 66cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3150043" role="paragraph" l10n="U" oldref="39">You want to give certain values in your tables particular emphasis. For example, in a table of turnovers, you can show all the values above the average in green and all those below the average in red. This is possible with conditional formatting.</paragraph> 67cdf0e10cSrcweir <list type="ordered"> 68cdf0e10cSrcweir <listitem> 69cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3155337" role="listitem" l10n="U" oldref="40">First of all, write a table in which a few different values occur. For your test you can create tables with any random numbers:</paragraph> 70cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3149565" role="listitem" l10n="U" oldref="41">In one of the cells enter the formula =RAND(), and you will obtain a random number between 0 and 1. If you want integers of between 0 and 50, enter the formula =INT(RAND()*50).</paragraph> 71cdf0e10cSrcweir </listitem> 72cdf0e10cSrcweir <listitem> 73cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3149258" role="listitem" l10n="U" oldref="42">Copy the formula to create a row of random numbers. Click the bottom right corner of the selected cell, and drag to the right until the desired cell range is selected.</paragraph> 74cdf0e10cSrcweir </listitem> 75cdf0e10cSrcweir <listitem> 76cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3159236" role="listitem" l10n="U" oldref="43">In the same way as described above, drag down the corner of the rightmost cell in order to create more rows of random numbers.</paragraph> 77cdf0e10cSrcweir </listitem> 78cdf0e10cSrcweir </list> 79cdf0e10cSrcweir <paragraph xml-lang="en-US" id="hd_id3149211" role="heading" level="3" l10n="U" 80cdf0e10cSrcweir oldref="44">Step 2: Define Cell Styles</paragraph> 81cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3154659" role="paragraph" l10n="U" oldref="45">The next step is to apply a cell style to all values that represent above-average turnover, and one to those that are below the average. Ensure that the Styles and Formatting window is visible before proceeding.</paragraph> 82cdf0e10cSrcweir <list type="ordered"> 83cdf0e10cSrcweir <listitem> 84cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3150883" role="listitem" l10n="U" oldref="46">Click in a blank cell and select the command <emph>Format Cells</emph> in the context menu.</paragraph> 85cdf0e10cSrcweir </listitem> 86cdf0e10cSrcweir <listitem> 87cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3155529" role="listitem" l10n="U" oldref="47">In the <emph>Format Cells</emph> dialog on the <emph>Background</emph> tab, select a background color. Click <emph>OK</emph>.</paragraph> 88cdf0e10cSrcweir </listitem> 89cdf0e10cSrcweir <listitem> 90cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3154484" role="listitem" l10n="U" oldref="48">In the Styles and Formatting window, click the <emph>New Style from Selection</emph> icon. Enter the name of the new style. For this example, name the style "Above".</paragraph> 91cdf0e10cSrcweir </listitem> 92cdf0e10cSrcweir <listitem> 93cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3152889" role="listitem" l10n="U" oldref="49">To define a second style, click again in a blank cell and proceed as described above. Assign a different background color for the cell and assign a name (for this example, "Below").</paragraph> 94cdf0e10cSrcweir </listitem> 95cdf0e10cSrcweir </list> 96cdf0e10cSrcweir <paragraph xml-lang="en-US" id="hd_id3148704" role="heading" level="3" l10n="U" 97cdf0e10cSrcweir oldref="60">Step 3: Calculate Average</paragraph> 98cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3148837" role="paragraph" l10n="U" oldref="51">In our particular example, we are calculating the average of the random values. The result is placed in a cell:</paragraph> 99cdf0e10cSrcweir <list type="ordered"> 100cdf0e10cSrcweir <listitem> 101cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3144768" role="listitem" l10n="CHG" oldref="52">Set the cursor in a blank cell, for example, J14, and choose <emph>Insert - Function</emph>.</paragraph> 102cdf0e10cSrcweir </listitem> 103cdf0e10cSrcweir <listitem> 104cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3156016" role="listitem" l10n="CHG" oldref="53">Select the AVERAGE function. Use the mouse to select all your random numbers. If you cannot see the entire range, because the Function Wizard is obscuring it, you can temporarily shrink the dialog using the <link href="text/shared/00/00000001.xhp#eingabesymbol" name="Shrink or Maximize"><item type="menuitem">Shrink / Maximize</item></link> icon.</paragraph> 105cdf0e10cSrcweir </listitem> 106cdf0e10cSrcweir <listitem> 107cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3153246" role="listitem" l10n="U" oldref="54">Close the Function Wizard with <item type="menuitem">OK</item>.</paragraph> 108cdf0e10cSrcweir </listitem> 109cdf0e10cSrcweir </list> 110cdf0e10cSrcweir <paragraph xml-lang="en-US" id="hd_id3149898" role="heading" level="3" l10n="U" 111cdf0e10cSrcweir oldref="50">Step 4: Apply Cell Styles</paragraph> 112cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3149126" role="paragraph" l10n="U" oldref="55">Now you can apply the conditional formatting to the sheet:</paragraph> 113cdf0e10cSrcweir <list type="ordered"> 114cdf0e10cSrcweir <listitem> 115cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3150049" role="listitem" l10n="U" oldref="56">Select all cells with the random numbers.</paragraph> 116cdf0e10cSrcweir </listitem> 117cdf0e10cSrcweir <listitem> 118cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3153801" role="listitem" l10n="U" oldref="57">Choose the <emph>Format - Conditional Formatting</emph> command to open the corresponding dialog.</paragraph> 119cdf0e10cSrcweir </listitem> 120cdf0e10cSrcweir <listitem> 121cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3153013" role="listitem" l10n="U" oldref="58">Define the condition as follows: If cell value is less than J14, format with cell style "Below", and if cell value is greater than or equal to J14, format with cell style "Above".</paragraph> 122cdf0e10cSrcweir </listitem> 123cdf0e10cSrcweir </list> 124cdf0e10cSrcweir <paragraph xml-lang="en-US" id="hd_id3155761" role="heading" level="3" l10n="U" 125cdf0e10cSrcweir oldref="61">Step 5: Copy Cell Style</paragraph> 126cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3145320" role="paragraph" l10n="U" oldref="62">To apply the conditional formatting to other cells later:</paragraph> 127cdf0e10cSrcweir <list type="ordered"> 128cdf0e10cSrcweir <listitem> 129cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3153074" role="listitem" l10n="U" oldref="63">Click one of the cells that has been assigned conditional formatting.</paragraph> 130cdf0e10cSrcweir </listitem> 131cdf0e10cSrcweir <listitem> 132cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3149051" role="listitem" l10n="U" oldref="64">Copy the cell to the clipboard.</paragraph> 133cdf0e10cSrcweir </listitem> 134cdf0e10cSrcweir <listitem> 135cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3150436" role="listitem" l10n="U" oldref="65">Select the cells that are to receive this same formatting.</paragraph> 136cdf0e10cSrcweir </listitem> 137cdf0e10cSrcweir <listitem> 138cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3147298" role="listitem" l10n="U" oldref="66">Choose <emph>Edit - Paste Special</emph>. The <emph>Paste Special</emph> dialog appears.</paragraph> 139cdf0e10cSrcweir </listitem> 140cdf0e10cSrcweir <listitem> 141cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3166465" role="listitem" l10n="U" oldref="67">In the <emph>Selection</emph> area, check only the <emph>Formats</emph> box. All other boxes must be unchecked. Click <emph>OK</emph>.</paragraph> 142cdf0e10cSrcweir </listitem> 143cdf0e10cSrcweir </list> 144cdf0e10cSrcweir <section id="relatedtopics"> 145cdf0e10cSrcweir <embed href="text/scalc/guide/cellstyle_by_formula.xhp#cellstyle_by_formula"/> 146cdf0e10cSrcweir <embed href="text/scalc/guide/cellstyle_minusvalue.xhp#cellstyle_minusvalue"/> 147cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id3159123" role="paragraph" l10n="U" oldref="68"><link href="text/scalc/01/05120000.xhp" name="Format - Conditional formatting">Format - Conditional formatting</link></paragraph> 148cdf0e10cSrcweir </section> 149cdf0e10cSrcweir </body> 150cdf0e10cSrcweir</helpdocument>