突出显示重叠的date范围
我正在尝试突出显示Excel中每个人的重叠date范围。
到目前为止,我提出了这个公式:
=SUMMENPRODUKT(($D3<=$E$3:$E$10000)*($E3>=$D$3:$D$10000))>1
但是,我很难只突出显示给定人员(例如Jeff)具有重叠date范围的那些行。
非VBA
=AND(COUNTIFS($D$6:$D$12,">="&$C6,$C$6:$C$12,"<="&$D6)>1,$B6="Jeff")
或者是指整个C&D栏目
=AND(COUNTIFS($D:$D,">="&$C6,$C:$C,"<="&$D6)>1,$B6="Jeff")
引用图像中的单元格,并将条件格式应用于单元格A6:D12
(如果你的意思是只有杰夫,如果他与任何人有重叠的范围突出显示)
要么
=COUNTIFS($D$6:$D$12,">="&$C6,$C$6:$C$12,"<="&$D6,$B$6:$B$12,$B6)>1
或者是指整个B,C和D列
=COUNTIFS($D:$D,">="&$C6,$C:$C,"<="&$D6,$B:$B,$B6)>1
(如果你的意思是强调与自己重叠的人)
如果可能的话,比使用SUMPRODUCT的数组types的解决scheme,使用COUNTIFS通常更好。
使用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