简体   繁体   English

Excel条件格式 - 根据每列顶部的值突出显示单元格

[英]Excel conditional formatting - highlight cells based on a value at the top of each column

I have a worksheet containing dates when people have attended training courses. 我有一份工作表,其中包含人们参加培训课程的日期。 Each column relates to a different course and may need to be redone at different intervals. 每列涉及不同的过程,可能需要以不同的间隔重做。 The interval (number of years) is shown at the top of each column. 间隔(年数)显示在每列的顶部。

I want a rule so that each cell's formatting is based on the value at the top of its column, so I can have one rule for the the whole worksheet, rather than needing a new rule for each column. 我想要一个规则,以便每个单元格的格式基于其列顶部的值,因此我可以为整个工作表设置一个规则,而不是每个列都需要一个新规则。 If the value in the interval cell is 'N' it means that course doesn't have to be resat, so no formatting required. 如果区间单元格中的值为“N”,则表示该过程不必重新进行,因此不需要格式化。 Otherwise, if the date in the cell is older than the interval (in number of years), apply some formatting. 否则,如果单元格中的日期早于间隔(以年数表示),请应用一些格式。

I've come close. 我走近了。 I've got the rule =IF($C$5="N", ,TODAY()-($C$5*365)) and this works (where C5 contains the retraining interval). 我有规则= IF($ C $ 5 =“N”,,TODAY() - ($ C $ 5 * 365))这是有效的(其中C5包含再训练间隔)。 However I need the last step of being able to reference row 5 of the column the cell belongs to so I don't have to make a new rule for each column. 但是,我需要能够引用单元格所属列的第5行的最后一步,因此我不必为每列创建新规则。

        Course A     Course B     Course C
How often?  N          2             5

fred    1/01/2010   1/01/2010   1/01/2010
John    1/01/2011   1/01/2011   1/01/2011
Mary    1/01/2012   1/01/2012   1/01/2012

You need to remove the absolute column reference by deleting the "$" in front of the "C"s: 您需要通过删除“C”前面的“$”来删除绝对列引用:

=IF(C$5="N", ,TODAY()-(C$5*365)) 

Now the formatting will refer to whichever column it's called from. 现在,格式化将引用它所调用的任何列。 Just make sure that when you enter it the active cell is in column C. 只需确保输入时活动单元格在C列中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM