简体   繁体   English

Excel Macro来计算每月的工作日/小时数

[英]Excel Macro to calculate number of working days/hours for each month

I have a start date and end date in two columns. 我在两列中有开始日期和结束日期。 There are 12 other columns one for each month. 每月还有另外12列。 I am trying to run a macro which gives the number of working hours/days for each month in those 12 columns based on the start and end date 我正在尝试运行一个宏,该宏根据开始和结束日期在这12列中给出每个月的工作时间/天数

Assuming you have holidays on saturdays and sundays, you can try the below formula, 假设您在星期六和星期日有假期,可以尝试以下公式,

=NETWORKDAYS(A2,B2,$G$2:$G$4)

Where G2:G4 is the holiday range. 其中G2:G4是假期范围。 This is optional. 这是可选的。 在此处输入图片说明

Excel has another function which allows you to alter your weekends, Excel还有另一个功能,可让您更改周末,

=NETWORKDAYS.INTL (start_date, end_date, [weekend], [holidays])

You can specify weekends and holidays as well. 您还可以指定周末和节假日。 The below formula indicates that all days in a week are working days, (column E) 下面的公式表明一周中的所有天都是工作日,(E列)

=NETWORKDAYS.INTL(A2,B2,"0000000")

If you have only 8 working hours a day, just multiply the difference with 8. Hope this helps 如果您每天只有8个工作小时,只需将差值乘以8。希望这会有所帮助

You can use the NetworkDays formula for this. 您可以为此使用NetworkDays公式。

=NETWORKDAYS(StartDate, EndDate, [Holidays])

If you don't want Excel to count bank holidays you will need to supply the formula with a list. 如果您不希望Excel计算银行假期,则需要为公式提供一个列表。

The number of working hours in a day isn't standard. 一天的工作时间不是标准的。 You will need to calculate this yourself ( Working Days * Working Hours in Day ). 您需要自己计算( Working Days * Working Hours in Day )。

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

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