<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
	
<!--
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 -->
 
	
<meta>
      <topic id="textscalcguidecellstyle_conditionalxml" indexer="include" status="PUBLISH">
         <title xml-lang="en-US" id="tit">Applying Conditional Formatting</title>
         <filename>/text/scalc/guide/cellstyle_conditional.xhp</filename>
      </topic>
   </meta>
   <body>
<bookmark xml-lang="en-US" branch="index" id="bm_id3149263"><bookmark_value>conditional formatting; cells</bookmark_value>
      <bookmark_value>cells; conditional formatting</bookmark_value>
      <bookmark_value>formatting; conditional formatting</bookmark_value>
      <bookmark_value>styles;conditional styles</bookmark_value>
      <bookmark_value>cell formats; conditional</bookmark_value>
      <bookmark_value>random numbers;examples</bookmark_value>
      <bookmark_value>cell styles; copying</bookmark_value>
      <bookmark_value>copying; cell styles</bookmark_value>
      <bookmark_value>tables; copying cell styles</bookmark_value>
</bookmark><comment>mw deleted "formats;"</comment>
<paragraph xml-lang="en-US" id="hd_id3149263" role="heading" level="1"><variable id="cellstyle_conditional"><link href="text/scalc/guide/cellstyle_conditional.xhp">Applying Conditional Formatting</link>
</variable></paragraph>
      <paragraph xml-lang="en-US" id="par_id3159156" role="paragraph">Using the menu command <emph>Format - Conditional - Condition</emph>, the dialog allows you to define conditions per cell, which must be met in order for the selected cells to have a particular format.</paragraph>
      <paragraph xml-lang="en-US" id="par_id8039796" role="warning">To apply conditional formatting, AutoCalculate must be enabled. Choose <emph>Data - Calculate - AutoCalculate</emph> (you see a check mark next to the command when AutoCalculate is enabled).</paragraph>
      <paragraph xml-lang="en-US" id="par_id3154944" role="paragraph">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>
      <h2 id="hd_id4480727">To Define the Conditions</h2>
      <list type="ordered">
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3154490" role="listitem">Select the cells to which you want to apply a conditional style.</paragraph>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3155603" role="listitem">Choose <emph>Format - Conditional - Condition</emph>.</paragraph>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3146969" role="listitem">Enter the condition(s) into the dialog box. The dialog is described in detail in <link href="text/scalc/01/05120000.xhp">$[officename] Help</link>, and an example is provided below:</paragraph>
         </listitem>
      </list>
      <h2 id="hd_id3155766">Example of Conditional Formatting: Highlighting Totals Above/Under the Average Value</h2>
      <h3 id="hd_id4341868">Step1: Generate Number Values</h3>
      <paragraph xml-lang="en-US" id="par_id3150043" role="paragraph">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>
      <list type="ordered">
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3155337" role="listitem">First of all, create a table in which a few different values occur. For your test you can create tables with any random numbers:</paragraph>
            <paragraph xml-lang="en-US" id="par_id3149565" role="listitem">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>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3149258" role="listitem">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>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3159236" role="listitem">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>
         </listitem>
      </list>
      <h3 id="hd_id3149211">Step 2: Define Cell Styles</h3>
      <paragraph xml-lang="en-US" id="par_id3154659" role="paragraph">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 window is visible before proceeding.</paragraph>
      <list type="ordered">
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3150883" role="listitem">Click in a blank cell and select the command <emph>Format Cells</emph> in the context menu.</paragraph>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3155529" role="listitem">In the <emph>Format Cells</emph> dialog on the <emph>Background</emph> tab, click the <emph>Color</emph> button and then select a background color. Click <emph>OK</emph>.</paragraph>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3154484" role="listitem">In the Styles deck of the Sidebar, click the <emph>New Style from Selection</emph> icon. Enter the name of the new style. For this example, name the style "Above".</paragraph>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3152889" role="listitem">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>
         </listitem>
      </list>
      <h3 id="hd_id3148704">Step 3: Calculate Average</h3>
      <paragraph xml-lang="en-US" id="par_id3148837" role="paragraph">In our particular example, we are calculating the average of the random values. The result is placed in a cell:</paragraph>
      <list type="ordered">
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3144768" role="listitem">Set the cursor in a blank cell, for example, J14, and choose <emph>Insert - Function</emph>.</paragraph>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3156016" role="listitem">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#shrink_maximize"><item type="menuitem">Shrink</item></link> icon.</paragraph>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3153246" role="listitem">Close the Function Wizard with <item type="menuitem">OK</item>.</paragraph>
         </listitem>
      </list>
      <h3 id="hd_id3149898">Step 4: Apply Cell Styles</h3>
      <paragraph xml-lang="en-US" id="par_id3149126" role="paragraph">Now you can apply the conditional formatting to the sheet:</paragraph>
      <list type="ordered">
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3150049" role="listitem">Select all cells with the random numbers.</paragraph>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3153801" role="listitem">Choose the <emph>Format - Conditional - Condition</emph> command to open the corresponding dialog.</paragraph>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3153013" role="listitem">Define the condition as follows: If cell value is less than $J$14, format with cell style "Below", and if cell value is greater than or equal to $J$14, format with cell style "Above".</paragraph>
         </listitem>
      </list>
      <h3 id="hd_id3155761">Step 5: Copy Cell Style</h3>
      <paragraph xml-lang="en-US" id="par_id3145320" role="paragraph">To apply the conditional formatting to other cells later:</paragraph>
      <list type="ordered">
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3153074" role="listitem">Click one of the cells that has been assigned conditional formatting.</paragraph>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3149051" role="listitem">Copy the cell to the clipboard.</paragraph>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3150436" role="listitem">Select the cells that are to receive this same formatting.</paragraph>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3147298" role="listitem">Choose <emph>Edit - Paste Special - Paste Special</emph>. The <emph>Paste Special</emph> dialog appears.</paragraph>
         </listitem>
         <listitem>
            <paragraph xml-lang="en-US" id="par_id3166465" role="listitem">In the <emph>Paste</emph> area, check only the <emph>Formats</emph> box. All other boxes must be unchecked. Click <emph>OK</emph>. Or you can click the <emph>Formats only</emph> button instead.</paragraph>
         </listitem>
      </list>
      <section id="relatedtopics">
         <embed href="text/scalc/guide/cellstyle_by_formula.xhp#cellstyle_by_formula"/>
         <embed href="text/scalc/guide/cellstyle_minusvalue.xhp#cellstyle_minusvalue"/>
         <paragraph xml-lang="en-US" id="par_id3159123" role="paragraph"><link href="text/scalc/01/05120000.xhp">Format - Conditional - Condition</link></paragraph>
      </section>
   </body>
</helpdocument>
