简体   繁体   中英

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. 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). 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.

        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:

=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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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