# 💡 條件格式：自訂公式

{% hint style="warning" %}

* 使用「<mark style="color:red;">**自訂公式**</mark>」時，只要寫「<mark style="color:red;">**第一個儲存格**</mark>」的公式就可以❗️
* 注意：公式前面要有「<mark style="color:red;">**等號**</mark>」(<mark style="color:red;">**=**</mark>)
  {% endhint %}

{% tabs %}
{% tab title="💈範例" %}

```excel-formula
# 第一個儲存格的公式
# 儲存格非空白，且文字轉為數字後，其值 < 60
=AND(NOT(ISBLANK(C8)),VALUE(C8)<60)
```

![](https://2527454625-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfvEFZnSBhKT6fJmus0%2Fuploads%2Fd0QtOuTeTUv1RuDpfgM8%2Fconditional-formatting.jpg?alt=media\&token=b18b3040-c86a-48ec-a656-7746c013f722)

* 其他範例

```excel-formula
# A1:A100 內有重複的值
=COUNTIF($A$1:$A$100,A1)>1

# 假設選擇 A:F
# 下列的條件可以設定「整列」的格式(如果第一格 = 1)
=$A1=1
```

{% endtab %}

{% tab title="📘 手冊" %}

* Google Help ⟩&#x20;
  * [Work with data](https://support.google.com/docs/topic/1361472?hl=en)
    * [Use conditional formatting rules in Google Sheets](https://support.google.com/docs/answer/78413)
  * [AND](https://support.google.com/docs/answer/3093301?hl=en) function
  * [Logical functions](https://support.google.com/docs/topic/3105413?hl=en\&ref_topic=3046366): <mark style="color:red;">**NOT**</mark>, <mark style="color:red;">**OR**</mark>, ...
  * [ISBLANK](https://support.google.com/docs/answer/3093290?hl=en) function
    {% endtab %}

{% tab title="⬇️ 應用" %}

* [class-average](https://lochiwei.gitbook.io/web/appendix/gas/projects/class-average "mention") - 用紅色底色顯示平均低於 60 的分數。
  {% endtab %}
  {% endtabs %}
