Formula to calculate working hours in a reference period

TaxSloth

New Member
Joined
Oct 25, 2022
Messages
11
Office Version
  1. 2021
Platform
  1. MacOS
So we do a lot of work that involves calculating how many IRS working hours an employee qualifies for in a given year / employment window. Essentially, it's 8 hours for every weekday in the year that they work. What I'm trying to create is a quick formula that can reference a date range using a Start Date value from one cell and an End Date value in another cell. So if it's say 4/1/2020 and 11/15/2020, I want it to report back a total of 8 hours per weekday in that period.

My current plan is to create an index with three columns - Date, Day, Hours - and basically prefill out a chart with 8 hours on qualified days, and then sum values in a range from that Start Date cell to the End Date cell. What I can't figure out is how to search for say cell A2's content in a separate sheet like vlookup, but instead of returning the value in index 3 of the array I want it to report back the cell name of that cell in the third column so I can use it in a SUM formula. That way I can SUM the values between Start Date and End Date on my table directly. This will let me put an Active row at the very end of the table to account for employees who work through the full year, since current employees don't have End Dates.

Below is a rough example of the index I'm working from, since I can't upload a direct workbook on the mac. I can't figure out a formula that I can use to reference the start and end dates provided and sum the values for those dates according to my index table. Alternate suggestions for how to accomplish this are welcome, but ideally help with the formula I need is preferred.

Start DateEnd DateTotal Hours
1/1/20201/6/2020XX
1/6/2020ActiveXX

DateDayHours
1/1/2020=text(A2,"ddd")8
1/2/2020|8
1/3/2020|8
1/4/2020|8
1/5/2020|8
1/6/2020|0
1/7/2020|0
1/8/2020|8
ACTIVEV0
 
It is 2:00 AM so I should be sleeping.

Can you just calculate the number of weekdays and multiply by 8?

T202211.xlsm
EFGHIJKL
21-Jan-2031-Dec-2030-Jun-2030-Nov-2030-Jun-2031-Jul-20
32096880
42096880192
2a
Cell Formulas
RangeFormula
F3,I3F3=SUMPRODUCT(--(WEEKDAY(ROW(INDIRECT(E2&":"&F2)),2)<6))*8
F4,L4,I4F4=SUM(--(WEEKDAY(ROW(INDIRECT(E2&":"&F2)),2)<6))*8
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
So, this is a more direct screenshot of it - in this one I'm doing the math for working hours in 2022. The start date for employee A is way back in 2019, so I needed it to treat 1/1/19 as 1/1/22.
=SUMIFS(Sheet1!C:C,Sheet1!A:A,IF(D4<1/1/22,1/1/22,">="&'Qualified Labor Calc'!D4),Sheet1!A:A,IF(ISNUMBER('Qualified Labor Calc'!E4),"<="&'Qualified Labor Calc'!E4,"<>0"))

That's the adjusted formula I'm working from now, and it seems to handle it smoothly - since my index is only the year of '22, it also handles the math for if the end date is a future date. So I think the problem is resolved as it is with this change, thankfully. I just need to create template files for the different year reports which we do already anyways.
 

Attachments

  • Screen Shot 2022-11-22 at 8.17.36 AM.png
    Screen Shot 2022-11-22 at 8.17.36 AM.png
    19.7 KB · Views: 9
Upvote 0
It is 2:00 AM so I should be sleeping.

Can you just calculate the number of weekdays and multiply by 8?

T202211.xlsm
EFGHIJKL
21-Jan-2031-Dec-2030-Jun-2030-Nov-2030-Jun-2031-Jul-20
32096880
42096880192
2a
Cell Formulas
RangeFormula
F3,I3F3=SUMPRODUCT(--(WEEKDAY(ROW(INDIRECT(E2&":"&F2)),2)<6))*8
F4,L4,I4F4=SUM(--(WEEKDAY(ROW(INDIRECT(E2&":"&F2)),2)<6))*8
Yeah, calculating the weekdays and multiplying by 8 is exactly what we're doing. I've managed to get it working with the formula I shared above.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top