使用條件式格式

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:定義儲存格樣式

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.

  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.

Please support us!