Update ooo320-m1
[ooovba.git] / helpcontent2 / source / text / scalc / guide / cellstyle_conditional.xhp
blobfe5b0785f537e782e020d8024510dd34d2b6720f
1 <?xml version="1.0" encoding="UTF-8"?>
2 <helpdocument version="1.0">
4 <!--
5 ***********************************************************************
7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 *
9 * Copyright 2008 by Sun Microsystems, Inc.
11 * OpenOffice.org - a multi-platform office productivity suite
13 * $RCSfile: soffice2xmlhelp.xsl,v $
14 * $Revision: 1.10 $
16 * This file is part of OpenOffice.org.
18 * OpenOffice.org is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU Lesser General Public License version 3
20 * only, as published by the Free Software Foundation.
22 * OpenOffice.org is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Lesser General Public License version 3 for more details
26 * (a copy is included in the LICENSE file that accompanied this code).
28 * You should have received a copy of the GNU Lesser General Public License
29 * version 3 along with OpenOffice.org. If not, see
30 * <http://www.openoffice.org/license.html>
31 * for a copy of the LGPLv3 License.
33 ************************************************************************
34 -->
37 <meta>
38 <topic id="textscalcguidecellstyle_conditionalxml" indexer="include" status="PUBLISH">
39 <title xml-lang="en-US" id="tit">Applying Conditional Formatting</title>
40 <filename>/text/scalc/guide/cellstyle_conditional.xhp</filename>
41 </topic>
42 </meta>
43 <body>
44 <bookmark xml-lang="en-US" branch="index" id="bm_id3149263"><bookmark_value>conditional formatting; cells</bookmark_value>
45 <bookmark_value>cells; conditional formatting</bookmark_value>
46 <bookmark_value>formatting; conditional formatting</bookmark_value>
47 <bookmark_value>styles;conditional styles</bookmark_value>
48 <bookmark_value>cell formats; conditional</bookmark_value>
49 <bookmark_value>random numbers;examples</bookmark_value>
50 <bookmark_value>cell styles; copying</bookmark_value>
51 <bookmark_value>copying; cell styles</bookmark_value>
52 <bookmark_value>tables; copying cell styles</bookmark_value>
53 </bookmark><comment>mw deleted "formats;"</comment>
54 <paragraph xml-lang="en-US" id="hd_id3149263" role="heading" level="1" l10n="U"
55 oldref="24"><variable id="cellstyle_conditional"><link href="text/scalc/guide/cellstyle_conditional.xhp" name="Applying Conditional Formatting">Applying Conditional Formatting</link>
56 </variable></paragraph>
57 <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>
58 <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>
59 <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>
60 <paragraph xml-lang="en-US" id="hd_id4480727" role="heading" level="2" l10n="NEW">To Define the Conditions</paragraph>
61 <list type="ordered">
62 <listitem>
63 <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>
64 </listitem>
65 <listitem>
66 <paragraph xml-lang="en-US" id="par_id3155603" role="listitem" l10n="U" oldref="28">Choose <emph>Format - Conditional Formatting</emph>.</paragraph>
67 </listitem>
68 <listitem>
69 <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>
70 </listitem>
71 </list>
72 <paragraph xml-lang="en-US" id="hd_id3155766" role="heading" level="2" l10n="U"
73 oldref="38">Example of Conditional Formatting: Highlighting Totals Above/Under the Average Value</paragraph>
74 <paragraph xml-lang="en-US" id="hd_id4341868" role="heading" level="3" l10n="NEW">Step1: Generate Number Values</paragraph>
75 <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>
76 <list type="ordered">
77 <listitem>
78 <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>
79 <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>
80 </listitem>
81 <listitem>
82 <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>
83 </listitem>
84 <listitem>
85 <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>
86 </listitem>
87 </list>
88 <paragraph xml-lang="en-US" id="hd_id3149211" role="heading" level="3" l10n="U"
89 oldref="44">Step 2: Define Cell Styles</paragraph>
90 <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>
91 <list type="ordered">
92 <listitem>
93 <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>
94 </listitem>
95 <listitem>
96 <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>
97 </listitem>
98 <listitem>
99 <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>
100 </listitem>
101 <listitem>
102 <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>
103 </listitem>
104 </list>
105 <paragraph xml-lang="en-US" id="hd_id3148704" role="heading" level="3" l10n="U"
106 oldref="60">Step 3: Calculate Average</paragraph>
107 <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>
108 <list type="ordered">
109 <listitem>
110 <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>
111 </listitem>
112 <listitem>
113 <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>
114 </listitem>
115 <listitem>
116 <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>
117 </listitem>
118 </list>
119 <paragraph xml-lang="en-US" id="hd_id3149898" role="heading" level="3" l10n="U"
120 oldref="50">Step 4: Apply Cell Styles</paragraph>
121 <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>
122 <list type="ordered">
123 <listitem>
124 <paragraph xml-lang="en-US" id="par_id3150049" role="listitem" l10n="U" oldref="56">Select all cells with the random numbers.</paragraph>
125 </listitem>
126 <listitem>
127 <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>
128 </listitem>
129 <listitem>
130 <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>
131 </listitem>
132 </list>
133 <paragraph xml-lang="en-US" id="hd_id3155761" role="heading" level="3" l10n="U"
134 oldref="61">Step 5: Copy Cell Style</paragraph>
135 <paragraph xml-lang="en-US" id="par_id3145320" role="paragraph" l10n="U" oldref="62">To apply the conditional formatting to other cells later:</paragraph>
136 <list type="ordered">
137 <listitem>
138 <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>
139 </listitem>
140 <listitem>
141 <paragraph xml-lang="en-US" id="par_id3149051" role="listitem" l10n="U" oldref="64">Copy the cell to the clipboard.</paragraph>
142 </listitem>
143 <listitem>
144 <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>
145 </listitem>
146 <listitem>
147 <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>
148 </listitem>
149 <listitem>
150 <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>
151 </listitem>
152 </list>
153 <section id="relatedtopics">
154 <embed href="text/scalc/guide/cellstyle_by_formula.xhp#cellstyle_by_formula"/>
155 <embed href="text/scalc/guide/cellstyle_minusvalue.xhp#cellstyle_minusvalue"/>
156 <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>
157 </section>
158 </body>
159 </helpdocument>