- 公開日:
スプレッドシートの条件付き書式で別シートを参照する方法
Google スプレッドシートでは、関数を利用することによって、別のシートを参照して、条件付き書式を設定することが可能です。
この記事では、スプレッドシートにおける条件付き書式の条件を、別シートから参照する方法を分かりやすく紹介します。
スプレッドシートの条件付き書式で別シートを参照する方法
Google スプレッドシートで別シートから参照して条件付き書式を設定する場合、INDIRECT関数を使用します。
INDIRECT関数とは、指定されたセルの入力内容を返す関数です。INDIRECT関数を利用して、別シートのセルを指定し、その内容に応じた条件を設定します。
以下より、スプレッドシートの条件付き書式で、INDIRECT関数をカスタム数式で利用し、別シートの内容を条件とする方法を詳しく解説します。
別シートの特定のセルを条件とする
![表示形式をクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets1.png)
「表示形式」をクリックします。
![条件付き書式をクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets2.png)
「条件付き書式」を選択します。
![データ範囲を選択をクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets3.png)
「データ範囲を選択」をクリックします。
![データ範囲の選択](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets4.png)
「データ範囲の選択」が表示されます。
①条件の対象となるセルを選択し、②「OK」ボタンをクリックします。
![セルの書式設定の条件…をクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets5.png)
「セルの書式設定の条件…」をクリックします。
![カスタム数式をクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets6.png)
「カスタム数式」を選択します。
![値または数式をクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets7.png)
「値または数式」をクリックします。
![数式を入力](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets8.png)
「=INDIRECT("'シート2'!"&CELL("address",$B2))=TRUE
」と入力します。
これは「シート2のB2セルを参照し、もしチェックボックスがチェックされていれば」を意味します。
![塗りつぶしをクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets9.png)
「塗りつぶし」をクリックします。
![色を選択](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets10.png)
色(例:明るいオレンジ 3)を選択します。
![完了をクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets11.png)
「完了」ボタンをクリックします。
![シート2をクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets12.png)
条件付き書式設定ルールが追加されました。
シート2をクリックします。
![チェックボックスをクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets13.png)
条件としたB2セルはチェックがないのでFALSEと表示されています。
B2セルのチェックボックスをクリックし、チェックを入れます。
![シート1をクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets14.png)
チェックを入れることで、TRUEと表示されました。
シート1をクリックします。
![別シートを参照した](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets15.png)
セルの色が変わりました。
これで別シートのセルを参照して条件付き書式を設定できました。
別シートの範囲を条件とする
別シートの範囲にあるセルのいずれかを条件とする場合、COUNTIF関数を併用します。
COUNTIF関数とは、指定した範囲内にあるセルから、特定の条件に当てはまるセルの数をカウントする関数です。
以下より、別シートの範囲にあるセルのいずれかを条件とする設定方法を詳しく解説します。
![データ範囲の選択](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets16.png)
「データ範囲の選択」を開き、①条件の対象となる範囲を選択し、②「OK」ボタンをクリックします。
![数式を入力](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets17.png)
「カスタム数式」に「=COUNTIF(INDIRECT("シート2!$B3:$D6"),TRUE)
」と入力します。
これは「シート2のB3からD6の範囲を参照して、もし範囲内のいずれかのチェックボックスがチェックされていたら」を意味します。
![色を選択](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets18.png)
「塗りつぶし」で色(例:明るい緑 3)を選択します。
![シート2をクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets19.png)
条件付き書式設定ルールが追加されました。
シート2をクリックします。
![チェックボックスをクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets20.png)
条件とした範囲内のチェックボックスをクリックし、チェックを入れます。
![シート1をクリック](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets21.png)
チェックを入れました。
シート1をクリックします。
![別シートの範囲で設定完了](https://g-tips.jp/wp-content/uploads/how-to-reference-other-sheets-with-conditional-formatting-in-spreadsheets22.png)
設定した範囲の色が変わりました。
これで別シートの範囲を参照して条件付き書式を設定できました。