我试图在Excel中为每个人单独突出显示重叠的日期范围。
到目前为止,我想出了这个公式:
=SUMMENPRODUKT(($D3<=$E$3:$E$10000)*($E3>=$D$3:$D$10000))>1
但是我很难突出显示给定人员(例如Jeff)具有重叠日期范围的那些行。
答案 0 :(得分:1)
使用VBA
Dim currentcell, considerationcell as Range
For each currentcell in Range("C6:C12")
For each considerationcell in Range("C6:C12")
If currentcell.Address=considerationcell.Address Then
GoTo nextiteration
End If
If currentcell >= considerationcell and currentcell <= considerationcell.Offset(0,1) Then
Range(considerationcell.Offset(0,-2), considerationcell.Offset(0,1)).Interior.Color = RGB(111,111,111)
End If
If currentcell.Offset(0,1) >= considerationcell and currentcell.Offset(0,1) <= considerationcell.Offset(0,1) Then
Range(considerationcell.Offset(0,-2), considerationcell.Offset(0,1)).Interior.Color = RGB(111,111,111)
End If
nextiteration:
Next
Next
答案 1 :(得分:1)
非VBA
=AND(COUNTIFS($D$6:$D$12,">="&$C6,$C$6:$C$12,"<="&$D6)>1,$B6="Jeff")
或指整列C&amp; d
=AND(COUNTIFS($D:$D,">="&$C6,$C:$C,"<="&$D6)>1,$B6="Jeff")
引用图像中的单元格并将条件格式应用于单元格A6:D12
(如果你的意思是只强调Jeff,如果他与任何人有重叠的范围)
OR
=COUNTIFS($D$6:$D$12,">="&$C6,$C$6:$C$12,"<="&$D6,$B$6:$B$12,$B6)>1
或指整列B,C&amp; d
=COUNTIFS($D:$D,">="&$C6,$C:$C,"<="&$D6,$B:$B,$B6)>1
(如果你的意思是突出显示与自己重叠的人)
如果可能的话,使用COUNTIFS通常比使用SUMPRODUCT的阵列类型解决方案更好。