应用条件格式

Using the menu command Format - Conditional - Condition, the dialog allows you to define conditions per cell, which must be met in order for the selected cells to have a particular format.

警告图标

要应用条件格式,必须启用自动计算。请选择「工具 - 单元格内容 - 自动计算」 (启用自动计算后,将会看到该命令旁边的复选标记)。


使用条件格式,可以高亮显示超过总计平均值的总计。如果总计改变,则格式也相应改变,无需手动应用其他样式。

定义条件

  1. 选择要应用条件样式的单元格。

  2. Choose Format - Conditional - Condition.

  3. 在对话框中输入条件。该对话框在 LibreOffice 帮助中有详细说明,下面是一个示例:

条件格式化示例: 高亮显示高于/低于平均值的总计值

步骤 1: 生成数字值

您想在您的工作表中特殊强调特定值。例如,规定在表格中所有平均值以上的数值为绿色,所有平均值以下的数值为红色。这可以通过条件格式化来实现。

  1. First of all, create a table in which a few different values occur. For your test you can create tables with any random numbers:

    在一个单元格中输入公式 =RAND(),您就可以得到一个介于 0 和 1 之间的随机数值。如果您想让所有的数值均介于 0 和 50 之间,则输入公式 =INT(RAND()*50)。

  2. 复制公式以创建随机数字行。点击选中单元格的右下角并向右拖动,直到选中了所需的单元格区域。

  3. 与上面所述的类似,向下拖动右下角的单元格,创建多行随机数字。

步骤 2: 定义单元格样式

下一个步骤是将一种单元格样式应用到所有高于平均营业额的值,将另一种样式应用至低于平均营业额的值。在继续之前,请确认「样式」窗口可见。

  1. 点击空白单元格,调出右键菜单,选择「单元格格式」。

  2. In the Format Cells dialog on the Background tab, click the Color button and then select a background color. Click OK.

  3. In the Styles deck of the Sidebar, click the New Style from Selection icon. Enter the name of the new style. For this example, name the style "Above".

  4. 要定义其他样式,请重新点击空白单元格,然后重复上述操作。为单元格指定不同的背景颜色和名称 (在本例中,指定为「Below」)。

步骤 3: 计算平均值

在下面的特殊示例中,将计算随机数值的平均值,并将结果显示在一个单元格中:

  1. 在某空白单元格 (例如,J14) 中定位光标,然后选择「插入 - 函数」。

  2. 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 Shrink icon.

  3. 点击「确定」关闭函数向导。

步骤 4: 应用单元格样式

现在可以将条件格式用于您的工作表中:

  1. 选择所有带随机数值的单元格。

  2. Choose the Format - Conditional - Condition command to open the corresponding dialog.

  3. 按如下定义条件: 单元格数值小于 J14 时,用"之下"单元格样式格式化;单元格数值大于或等于 J14 时,用"之上"单元格样式格式化。

步骤 5: 复制单元格样式

要将条件格式用于另一单元格:

  1. 点击指定为条件格式的单元格之一。

  2. 将单元格复制到剪贴板上。

  3. 选择包含同样格式的单元格。

  4. Choose Edit - Paste Special - Paste Special. The Paste Special dialog appears.

  5. In the Paste area, check only the Formats box. All other boxes must be unchecked. Click OK. Or you can click the Formats only button instead.

请支持我们!