Forum Discussion
Calculate total working hours between date/time excluding weekends and break time
- Jul 15, 2024
I attached the wrong version, sorry.
The 2 hours in the first example is because the 1st of May is in the holiday list. If you remove that date from the holiday list, you get 3 hours.
See the attached version.
HansVogelaar thanks dude it seems working just fine. But I can't copy it to my existing excel data. It always shows #NAME? can u help with that?
Open both my sample workbook and your workbook.
Press Alt+F11 to activate the Visual Basic Editor.
In the Project Explorer pane on the left hand side, expand TimeDifferenceWithBreak.xlsm, and Modules under it if necessary.
Drag Module1 to your workbook and drop it there.
Switch back to Excel.
Save your workbook as a macro-enabled workbook (*.xlsm)
- VladLockhartJul 16, 2024Copper ContributorHi thanks, I did as u told me. But how do I use it, how do I call function on the column i want? I'm really sorry I'm new to this.
- HansVogelaarJul 16, 2024MVP
Create a list of public holidays.
Select the list, and name it Holidays.
Now let's say you have a start date/time in D2 and the corresponding end date/time in E2.
In another cell, for example E2, enter the formula =TimeDiff(D2, E2)
This can be filled down if required.
- VladLockhartJul 17, 2024Copper Contributor
HansVogelaar Hi i tried like this. Is this right? Why is it still error? What do u mean by making a list of holidays?