条件付き書式設定を使う

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. 2 番目のスタイルを定義するには、もう一度、空のセルをクリックして、上記手順を繰り返します。別の背景色を割り当てて、今度は「下」という名前をスタイルに付けます。

ステップ3: 平均を計算する

この例では、これまでに作成した乱数の平均を計算します。計算結果は 1 つのセルに表示します。

  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. OKで関数ウィザードを閉じます。

ステップ4: セルスタイルを適用する

あとは条件付き書式設定を表に適用するだけです:

  1. 乱数が入力されている全てのセルを選択します。

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

  3. 条件を設定します: 値が 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.

ご支援をお願いします!