简体   繁体   English

如果列中的数据出现在日期范围内,则突出显示

[英]If Data in Column appears within Date Range then highlight

I would like to do some conditional formatting on a Project Planner that will highlight a persons name if the dates selected for an activity to which they are assigned fall within a date range for another action to which they are also assigned. 我想在项目计划器上进行一些条件格式化,如果为他们分配的活动选择的日期在另一个人也分配给他们的日期范围内,则该计划将突出显示人员姓名。

On my spreadsheet I have the following columns: 在我的电子表格中,我有以下几列:

  • Column A: Activity A栏:活动
  • Column B: Start Date B栏:开始日期
  • Column C: End Date C栏:结束日期
  • Column D: Responsible Person D栏:负责人

To give an example of how I would like the formula to work: 举一个我希望公式如何工作的示例:

Person A has been assigned an activity that begins on 01/02/14 and ends on 07/02/14. 已为人员A分配了一个活动,该活动开始于2014年1月2日,结束于2014年2月7日。 If a subsequent activity is then added to the sheet that either begins or ends on any of the dates within the range 01/02/14-07/02/14 and the person is assigned to it, i would like to use conditional formatting to highlight the cell as a sign to the user. 如果随后将随后的活动添加到在01/02 / 14-07 / 02/14范围内的任何日期开始或结束的工作表中,并且将人员分配给该工作表,我想使用条件格式来高亮显示该单元格作为对用户的标志。

Any help would be appreciated. 任何帮助,将不胜感激。

Thanks, 谢谢,

Ryan 瑞安

You could maybe use COUNTIFS with the conditional formatting: 您可以将COUNTIFS与条件格式一起使用:

=COUNTIFS(D:D,D1,B:B,"<="&C1,C:C,">="&B1)>1

This counts all the instances where the following conditions are satisfied: 这将计算满足以下条件的所有实例:

  1. The responsible person is the same person ( D:D, D1 part) 负责人是同一个人( D:D, D1部分)

  2. The dates the other activities begin are before or equal to the date a certain activity ends. 其他活动开始的日期早于或等于某个活动结束的日期。 ( B:B,"<="&C1 part) B:B,"<="&C1部分)

  3. The dates the other activities end are equal or after to the date a certain activity begins. 其他活动的结束日期等于或晚于某个特定活动的开始日期。 ( C:C,">="&B1 part) C:C,">="&B1部分)

The formula can make Excel respond quite slowly since it takes into consideration the whole column. 该公式可以使Excel响应速度很慢,因为它考虑了整个列。 Change it to a range if possible, for example, if you always have about 100 activities, you could maybe use: 尽可能将其更改为一个范围,例如,如果您始终有大约100个活动,则可以使用:

=COUNTIFS(D1:D120,D1,B1:B120,"<="&C1,C1:C120,">="&B1)>1

Here is what I get after using this conditional formatting: 这是使用这种条件格式后得到的结果:

在此处输入图片说明

COUNTIFS returns a number; COUNTIFS返回一个数字; a count of cells that satisfies the conditions. 满足条件的单元数。 Since we have >1 at the end, this means that the cell(s) will get highlighted if there is more than one cell with the same conditions. 由于结尾处的数字>1 ,因此,如果有多个相同条件的单元格,则该单元格将突出显示。

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

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