Excel条件格式: 根据某一列单元格的值, highlight整行

[追记 about excel Conditional Formatting Rules @2015-07-15  12:58]

 

发现了两个很好的URL

http://www.howtogeek.com/howto/45670/how-to-highlight-a-row-in-excel-using-conditional-formatting/

http://www.contextures.com/xlCondFormat02.html

 

尤其在第二个URL中, 包含了一个sample file.  包含了很多应用场景和实例, 足以满足我的各种需求.

http://www.contextures.com/CondFormat01.zip

我已经把这个文件转到了这篇blog的下载中.

另外, 当我想通过一个单元格的逻辑, 高亮highlight正行的时候, 发现在"Use a formula to determine which cell to format"中, 有如下去别. 详见上面的两个URL

 
结论: $是必须的.

//好用的case
=$A2="Released-by-Mercedes"

//因为少了$, 这个condition只能高亮一个单元格, 无法高亮正行
=A2="Released-by-Mercedes"

[原文 @2013-06-11 10:43]

 

最典型的应用场景是我们有很多条数据, 每一条数据(记录), 用excel的一行表示.

每条记录有一个时间,

我想根据日期的不同, 高亮显示(或者不高亮显示)整行,

比如, 如果我想, 如果对应的日期是周六或者周日, 将一整行(entire row)的颜色都设成灰色.

 

显然要使用条件格式来指定单元格的样式,

而条件格式的匹配要使用公式.

 

记得上次在2003中使用这个功能, 公式中引用的单元格是可以跟着行号自增长的.

比如, 我在16行, 对整行设定条件=$B$16="Sat",

然后将条件格式刷到17行的时候, 条件会自动变成=$B$17="Sat",

 

但是刚才在excel 2010中试验了一下, 貌似不好用,

又试了下=$B:$B="Sat"还是不好用.

 

于是google, 找到最稳妥的方法是使用indirect, 写成下面这样

=INDIRECT("B"&ROW())="Sun"

 

原文链接如下:

Conditional formatting, entire row based

看不懂indirect的可以参考原链接, 里面有一些变化的例子, 或者直接google.

 

这个链接中, 作者还给出了一个创建类似条件格式的详细步骤(如下).

其中的第9步, 我更习惯挪到最前面做,

直接在一开始, 就用鼠标在sheet中选择好我们想运用条件格式的区域.

写道
1 . Select Conditional Formatting
2 . Select New Rule
3 . Select "Use a Formula to determine which cells to format"
4 . Enter the Formula, =INDIRECT("g"&ROW())="X"
5 . Enter the Format you want (text color, fill color, etc).
6 . Select OK to save the new format
7 . Open "Manage Rules" in Conditional Formatting
8 . Select "This Worksheet" if you can't see your new rule.
9 . In the "Applies to" box of your new rule, enter =$A$1:$Z$1500 (or however wide/long you want the conditional formatting to extend depending on your worksheet)

 

猜你喜欢

转载自wjason.iteye.com/blog/1885342