IF formula on time cell not working

感情迁移 提交于 2020-01-06 05:28:23

问题


IF(AND(H$2>=$B2,H$2<=$C2),"X","") 

Works for 08:30-15:30 and 9:30-18:30, but it does for shift 19:30-4:30 check the image (highlighted in yellow cell)


回答1:


A "simple" solution would be to check if start is bigger than end. In that case, you will need to check for

time >= start OR time <= end

Something like :

=IF(
    $B2<$C2;
        IF(AND(H$2>=$B2;H$2<=$C2);"X";"");
        IF(OR( H$2>=$B2;H$2<=$C2);"X";"")
)



回答2:


Better to include date part into your formula of each cell showing time and re-format these cells to show the time part only. They include:
1. Start and end for each resource: For example, for B3, make it as "2018-07-02 08:30" and format it as "hh:mm";
2. Time marker in the header in the second row, i.e. for D2, E2, ..., sets up D2 as the starting point to include the date part as well, then sets cells after it increase 30 minuets from each previous cell. That is, sets E2 as =D2+TIME(0,30,0), and copy E2 right. Also re-format all these cells as "hh:mm";
3. Date marker in the header in first row, i.e. for D1, AM1, ..., let D1 as =D2 and format as date (and merge cells of course) , then copy right.
In this way, the formula should work and the cells' format looks same.



来源:https://stackoverflow.com/questions/51238467/if-formula-on-time-cell-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!