如何根据另一个单元格设置 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。区域下拉可减少拼写不一致。规则应从活动单元格写起,并分清绝对引用与相对引用。
完整英文示例、公式与作者备注
Excel How-toTested 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
- Type the threshold in F1.
- Select B2:B10 (the sales column, not F1).
- Open Home > Conditional Formatting > New Rule.
- Choose Use a formula to determine which cells to format.
- Enter
=$B2>=$F$1. Write it as it should read for the active cell, usually the top-left cell of the selection. - Set a fill or a font color, then click OK.
In Google Sheets
- Select B2:B10.
- Open Format > Conditional formatting.
- Set Format cells if to Custom formula is.
- Enter
=$B2>=$F$1. - 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.