如何根據另一個單元格設定 Excel 條件格式

選中要變色的單元格,在 Excel 中開啟“開始 > 條件格式 > 新建規則 > 使用公式”,Google Sheets 在“格式 > 條件格式”中選“自定義公式”。閾值放在單獨的單元格並用絕對引用,例如 =$B2>=$F$1,這樣改 F1 就不必改規則。公式按所選區域左上角單元格來寫。

本文目錄

快速解答

選中要變色的單元格,在 Excel 中開啟“開始 > 條件格式 > 新建規則 > 使用公式”,Google Sheets 在“格式 > 條件格式”中選“自定義公式”。閾值放在單獨的單元格並用絕對引用,例如 =$B2>=$F$1,這樣改 F1 就不必改規則。公式按所選區域左上角單元格來寫。

=$B2>=$F$1

檢查重點

2026 年 11 月 12 日測試中 F1 為 2000 時,2500 對閾值的比較為 TRUE,1800 與 1200 為 FALSE。整行規則只鎖定列。東區且銷售額 2500 的 AND 條件為 TRUE,東區 1200 為 FALSE,因為 1200 低於閾值。日期比較必須使用真正的日期值。

邊界與相容性

跨表閾值可用 Settings 工作表上的絕對引用;個別舊版 Excel 若不接受跨表引用,可定義名稱或把閾值放在同一工作表。不要靠統計顏色來計數,應使用相同邏輯的 COUNTIFS。區域下拉可減少拼寫不一致。規則應從活動單元格寫起,並分清絕對引用與相對引用。

完整英文範例、公式與作者備註

Tested in: The threshold and comparison formulas below were evaluated in Google Sheets on 12 November 2026. Excel 365 menu names are the current desktop labels; I did not click through the rule dialogs in Excel this session.

This page is about rules that look at a different cell than the one being painted. For color scales, built-in “greater than” rules, and the basics of formula rules, see Conditional Formatting in Excel.

One threshold cell, many rows

Put the cutoff in its own cell so you can change it without editing the rule. On 12 November 2026 I used 2000 in F1 and tested three sales figures:

=2500>=$F$1
=1800>=$F$1
=1200>=$F$1

Those returned TRUE, FALSE, and FALSE. So 2500 would be formatted; 1800 and 1200 would not. If you write =$B2>=2000 instead, you have to open the rule every time the cutoff moves.

In Excel 365

  1. Type the threshold in F1.
  2. Select B2:B10 (the sales column, not F1).
  3. Open Home > Conditional Formatting > New Rule.
  4. Choose Use a formula to determine which cells to format.
  5. Enter =$B2>=$F$1. Write it as it should read for the active cell, usually the top-left cell of the selection.
  6. Set a fill or a font color, then click OK.

In Google Sheets

  1. Select B2:B10.
  2. Open Format > Conditional formatting.
  3. Set Format cells if to Custom formula is.
  4. Enter =$B2>=$F$1.
  5. Choose a color and click Done.

If the colors land on the wrong rows, the formula was probably written for a different active cell than the one Excel or Sheets is using. Select B2 first, then extend the range down, then write the formula with B2 in it.

Highlight a whole row from another column

Select A2:C10, not just column B, and lock the column you want to test:

=$A2="East"

Every cell in row 2 now looks at A2; row 3 looks at A3. In the same Sheets check, "East"="East" was TRUE and "West"="East" was FALSE.

To require both a region and a threshold, combine the tests:

=AND($A2="East",$B2>=$F$1)

With F1 still at 2000, AND("East"="East",2500>=$F$1) returned TRUE, and AND("East"="East",1200>=$F$1) returned FALSE. East with sales of 1200 does not pass, because 1200 is below the cutoff. A missing $ on A, such as =A2="East" applied to A2:C10, will test B2 and C2 as they walk right, and only the first column will behave.

The same pattern works for a quantity target in another cell: =$E2>=$G$1. A 40-unit order against a target of 35 returned TRUE in the 12 November 2026 check (=40>=35).

Dates, and a cell on another sheet

To format rows whose date is on or after a start date in F1 (a real date, not text), use:

=$A2>=$F$1

In the test workbook, =DATE(2024,3,4)>=DATE(2024,3,1) was TRUE and =DATE(2024,2,5)>=DATE(2024,3,1) was FALSE. If F1 is text that only looks like a date, the comparison will mis-fire; see dates stored as text.

A threshold on another sheet is just a qualified address:

=$B2>=Settings!$A$1

Keep Settings!$A$1 absolute so every row uses that one cell. If an older Excel build rejects a cross-sheet reference in a conditional formatting formula, define a name that points at Settings!$A$1 and use the name in the rule, or place a copy of the threshold on the same sheet.

The $ signs, and things that look like a broken rule

Write the formula for the active cell, then decide what should stay put. A threshold is almost always absolute ($F$1). A column that supplies the test for a whole row is mixed ($A2). Two columns compared in the same row, such as “actual vs target on this row,” are usually relative in the row and locked in the column: =$B2>=$C2.

Conditional formatting does not change the value in the cell, and you should not count colors with a formula. If you need a count of rows that meet the same test, use COUNTIFS or SUMPRODUCT with that logic, as in COUNTIF vs COUNTIFS vs SUMPRODUCT.

A drop-down for the region, from How to Add a Drop-Down List in Excel, keeps the text in column A consistent so =$A2="East" does not miss "east " with a trailing space. Existing values that were typed before the drop-down was added still need a cleanup.

Stop after you have one working rule and a threshold you can edit. A pile of overlapping formula rules, each pointing at a slightly different cell, is harder to debug than a helper column that holds the TRUE/FALSE test and a single format rule that looks at that helper.

Oscar

專注電子表格公式與排錯;具體測試環境和待驗證事項見各篇文章。

Tested in Google Sheets (via Sheets API) on 12 November 2026: a threshold of 2000 in F1, sales of 2500/1800/1200, AND with a region test, and two date comparisons. Excel 365 menu names are the current desktop labels; I did not click through these rules in Excel this session..

本主題下一篇:資料清理與錄入 Excel 按日期做條件格式(逾期、即將到期和週末)