我正在Excel中构建时间表(参见 Headers 图片)Excel time sheet
在 Headers 为 Time +/- 的列中,我试图编写一个公式来计算如果工作时间(从工作时间列AB计算)高于或低于最接近分钟的时间并带走8小时,因为这是标准工作日 .
我想出了这个
=IF(AA2>TIME(8,0,0),(ROUND($AA2*1440,0)/1440),IF(AA2<TIME(8,0,0),(ROUND($AA2*1440,0)/1440)))-TIME(8,0,0)
公式做了我想要的,但它似乎不正确,有关如何使其更好的任何建议?
2 回答
如果使用1904日期系统,则以下内容应该有效:
这需要
ROUND(AA2*1440,0)/1440
(已经熟悉OP)和8小时之间的差异 . 由于处理日期/时间指数(一天是1
),8小时可以表示为1/3
.您're using (ROUND($AA2*1440,0)/1440) several times in your formula. You could calculate this once in a separate column and just refer to the column several times in your formula. The column could even be hidden so it doesn' t为电子表格添加噪音 . 也可以在宏函数中执行它,只需从公式调用宏函数 . 可以在此处找到如何执行此操作的示例:How to call VBA function from Excel cells (2010)?