Calculate end date and time excluding non-work hours

Asbestos_Jen

Active Member
Joined
May 12, 2017
Messages
271
Office Version
  1. 2007
Platform
  1. Windows
I have a spreadsheet which currently calculates work due times using user-input start times and turn-around-times (index,match,match from a table). I would like to be able to change the formula to accomodate work hours and holidays. For example, work coded as "urgent" is due 3.5 business hours after receipt, and rush is received+1business day, and standard is received+2business days. I've found how to incorporate full business days into the formula using networkdays, but can't figure out portions of business days.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Here's the mini-sheet. You can see that the due date excluding non-work hours matches the manual due date when the TAT is more than a work day, but not for urgent files received late in the work day.


LoginTemplate_smaller.xlsx
ABCDEFGHIJKLMNOPQ
1Project #Sample TypeSample CountTATRecdTimeLatest Off Time dd-mmm-yy hh:mmDue TimeExcludeNonworkHoursTAT Add daysShould be due (manual)Sample TypeTAT CodeFBCT TAT time (days)BULK TAT time (days)FBCT TAT time (hours)BULK TAT time (hours)
223-0001FBCT1U05-Oct-23 15:2505-Oct-23 14:1005-Oct-23 18:2505-Oct-23 15:250.1306-Oct-23 09:25BULKn/an/an/an/an/a
323-0002BULK3S05-Oct-23 15:44n/a07-Oct-23 15:4410-Oct-23 15:442.0010-Oct-23 15:44FBCTU0.0830.14623.5
423-0003Enter due time#N/A#N/APTR0.83312024
523-0004Enter due time#N/A#N/AS224848
623-0005Enter due time#N/A#N/AA0.0830.14623.5
723-0006Enter due time#N/A#N/A
823-0007Enter due time#N/A#N/AHolidayListStartTime08:00
923-0008Enter due time#N/A#N/A1-Jan-23New Year's DayEndTime17:00
1023-0009Enter due time#N/A#N/A20-Feb-23Family Day
1123-0010Enter due time#N/A#N/A7-Apr-23Good Friday
1223-0011Enter due time#N/A#N/A22-May-23Victoria Day
1323-0012Enter due time#N/A#N/A1-Jul-23Canada Day
1423-0013Enter due time#N/A#N/A4-Sep-23Labour Day
1523-0014Enter due time#N/A#N/A9-Oct-23Thanksgiving
1623-0015Enter due time#N/A#N/A11-Nov-24Remembrance Day
1723-0016Enter due time#N/A#N/A25-Dec-23Christmas
1823-0017Enter due time#N/A#N/A1-Jan-24New Year's Day
Project Listings
Cell Formulas
RangeFormula
G2:G18G2=IFERROR(IF($B2="Bulk",$E2+INDEX('Project Listings'!$M$1:$O$6,MATCH($D2,'Project Listings'!$M$1:$M$6,0),MATCH('Project Listings'!$O$1,'Project Listings'!$M$1:$O$1,0)),IF(AND(Table1[[#This Row],[Sample Type]]="FBCT",Table1[[#This Row],[TAT]]="U"),Table1[[#This Row],[RecdTime]]+3/24,IF(AND($B2="FBCT",$D2="N/A"),$F2+20/24,$F2+INDEX('Project Listings'!$M$2:$O$6,MATCH('Project Listings'!$D2,'Project Listings'!$M$2:$M$6,0),MATCH('Project Listings'!$N$1,'Project Listings'!$M$1:$O$1))))),"Enter due time")
H2:H18H2=WORKDAY(E2,I2,HolidayList)+(E2-INT(E2))
I2:I18I2=IF($B2="Bulk",INDEX('Project Listings'!$M$1:$O$6,MATCH($D2,'Project Listings'!$M$1:$M$6,0),MATCH('Project Listings'!$O$1,'Project Listings'!$M$1:$O$1,0)),IF(AND($B2="FBCT",Table1[[#This Row],[TAT]]="U"),3/24,IF(AND($B2="FBCT",$D2="N/A"),20/24,INDEX('Project Listings'!$M$2:$O$6,MATCH('Project Listings'!$D2,'Project Listings'!$M$2:$M$6,0),MATCH('Project Listings'!$N$1,'Project Listings'!$M$1:$O$1)))))
N6:O6,N3:O4N3=P3/24
Named Ranges
NameRefers ToCells
bulk_TAT='Project Listings'!$O$1:$O$6G2:G3580, I2:I3580
fbct_tat='Project Listings'!$N$1:$N$6G2:G3580, I2:I3580
HolidayList='Project Listings'!$M$9:$M$18H2:H18
TAT='Project Listings'!$M$1:$M$6G2:G3580, I2:I3580
 
Upvote 0
I've been working at this, and here's what I've got working. Columns V:Z are helpers to get me to the due dates & times I want (Column L). It's not very elegant, but I'm limited to features in Excel 2007 as each computer in my company runs a different version of Office (grrr).

If anyone can think of a way to simplify the formulae besides just combining them into a single cell, please let me know. I will likely combine the formulae before I release the sheet for all users at the beginning of 2024.

2024_ProjectListings_Test_Reduced.xlsx
ABCDGHKLVWXYZAAABACADAEAFAGAHAIAJAK
1Project#Sample TypeSample CountTATSamples ReceivedAnalysis CompletedLatestTimeOffNEW!!! FileDueHours Left in WDAddDaysWD_RecdDate RecdTime RecdTATs and SampleTypesHolidayList
223-0001BULK2U03-Jan-23 08:463-Jan-23N/A03-Jan-23 12:160.340.15Tue3-Jan-2308:46:00TATBULKFBCTPTApplicationYearDateWkdayHolidayName
323-0002BULK6U03-Jan-23 09:253-Jan-23N/A03-Jan-23 12:550.320.15Tue3-Jan-2309:25:00U3.52.5n/acount business hours only20231-Jan-23SunNew Year's Day
423-0003BULK8U03-Jan-23 09:423-Jan-23N/A03-Jan-23 13:120.300.15Tue3-Jan-2309:42:00R24n/an/acount business days20232-Jan-23MonNew Year's Day Lieu
523-0004BULK3U03-Jan-23 10:373-Jan-23N/A03-Jan-23 14:070.270.15Tue3-Jan-2310:37:00S48n/an/acount business days202320-Feb-23MonFamily Day
623-0005FBCT1U03-Jan-23 11:343-Jan-2303-Jan-23 11:1503-Jan-23 14:040.230.10Tue3-Jan-2311:34:00A3.52.5n/aNot work hour dependent20237-Apr-23FriGood Friday
723-0006FBCT2N/A03-Jan-23 12:483-Jan-2303-Jan-23 10:5004-Jan-23 06:500.180.83Tue3-Jan-2312:48:00PTn/an/a672Count 28 calendar days202322-May-23MonVictoria Day
823-0007BULK2U03-Jan-23 13:463-Jan-23N/A04-Jan-23 08:160.130.15Tue3-Jan-2313:46:00N/An/a20n/aCount 20 hours from latest time off20231-Jul-23SatCanada Day
923-0008FBCT1U03-Jan-23 14:083-Jan-23N/A03-Jan-23 16:380.120.10Tue3-Jan-2314:08:0020233-Jul-23MonCanada Day Lieu
1023-0009FBCT4N/A04-Jan-23 08:304-Jan-2303-Jan-23 14:3804-Jan-23 10:380.350.83Wed4-Jan-2308:30:00BusinessHours20237-Aug-23MonCivic Holiday
1123-0010FBCT3N/A04-Jan-23 08:314-Jan-2303-Jan-23 15:0804-Jan-23 11:080.350.83Wed4-Jan-2308:31:00Open08:0020234-Sep-23MonLabour Day
1223-0011FBCT1N/A04-Jan-23 09:084-Jan-2303-Jan-23 15:0004-Jan-23 11:000.330.83Wed4-Jan-2309:08:00Close17:0020239-Oct-23MonThanksgiving
1323-0012BULK63S04-Jan-23 10:126-Jan-23N/A06-Jan-23 10:120.282.00Wed4-Jan-2310:12:00202311-Nov-23SatRemembrance Day
1423-0013FBCT3N/A04-Jan-23 10:134-Jan-2303-Jan-23 15:0504-Jan-23 11:050.280.83Wed4-Jan-2310:13:00202313-Nov-23MonRemembrance Day Lieu
1523-0014FBCT1U04-Jan-23 12:084-Jan-23N/A04-Jan-23 14:380.200.10Wed4-Jan-2312:08:58202325-Dec-23MonChristmas
1623-0015FBCT4N/A04-Jan-23 13:034-Jan-2304-Jan-23 11:3205-Jan-23 07:320.160.83Wed4-Jan-2313:03:00DATA VALIDATION RULES202326-Dec-23TueBoxing Day
1723-0016FBCT2N/A04-Jan-23 13:054-Jan-2304-Jan-23 12:3205-Jan-23 08:320.160.83Wed4-Jan-2313:05:00Dates20241-Jan-24MonNew Year's Day
1823-0017BULK20R04-Jan-23 13:455-Jan-23N/A05-Jan-23 13:450.141.00Wed4-Jan-2313:45:00earliest01-Jan-23 08:00202419-Feb-24MonFamily Day
1923-0018FBCT1U04-Jan-23 14:144-Jan-23N/A04-Jan-23 16:440.120.10Wed4-Jan-2314:14:00latest23-Nov-23 15:10202429-Mar-24FriGood Friday
2023-0019FBCT3N/A04-Jan-23 15:184-Jan-2304-Jan-23 14:5505-Jan-23 10:550.070.83Wed4-Jan-2315:18:00202420-May-24MonVictoria Day
2123-0020BULK4U04-Jan-23 15:435-Jan-23N/A05-Jan-23 10:130.050.15Wed4-Jan-2315:43:0020241-Jul-24MonCanada Day
2223-0021FBCT4N/A04-Jan-23 16:114-Jan-2304-Jan-23 14:1905-Jan-23 10:190.030.83Wed4-Jan-2316:11:0020245-Aug-24MonCivic Holiday
2323-0022FBCT3N/A04-Jan-23 16:134-Jan-2304-Jan-23 15:1405-Jan-23 11:140.030.83Wed4-Jan-2316:13:0020242-Sep-24MonLabour Day
2423-0023BULK3U05-Jan-23 08:005-Jan-23N/A05-Jan-23 11:300.370.15Thu5-Jan-2308:00:00202414-Oct-24MonThanksgiving
2523-0024BULK3U05-Jan-23 08:405-Jan-23N/A05-Jan-23 12:100.350.15Thu5-Jan-2308:40:00202411-Nov-24MonRemembrance Day
2623-0025BULK2S05-Jan-23 10:009-Jan-23N/A09-Jan-23 10:000.292.00Thu5-Jan-2310:00:00202425-Dec-24WedChristmas
2723-0026FBCT3N/A05-Jan-23 10:425-Jan-2304-Jan-23 12:0705-Jan-23 08:070.260.83Thu5-Jan-2310:42:00202426-Dec-24ThuBoxing Day
2823-0027FBCT1U05-Jan-23 12:315-Jan-23N/A05-Jan-23 15:010.190.10Thu5-Jan-2312:31:0020251-Jan-25WedNew Year's Day
2923-0028FBCT1U05-Jan-23 12:325-Jan-23N/A05-Jan-23 15:020.190.10Thu5-Jan-2312:32:00
3023-0029FBCT4N/A05-Jan-23 12:545-Jan-2305-Jan-23 11:1106-Jan-23 07:110.170.83Thu5-Jan-2312:54:00
3123-0030FBCT1U05-Jan-23 13:195-Jan-23N/A05-Jan-23 15:490.150.10Thu5-Jan-2313:19:00
3223-0031BULK18S05-Jan-23 14:076-Jan-23N/A09-Jan-23 14:070.122.00Thu5-Jan-2314:07:00
3323-0032FBCT3N/A05-Jan-23 15:525-Jan-2305-Jan-23 15:2006-Jan-23 11:200.050.83Thu5-Jan-2315:52:00
3423-0033FBCT4N/A05-Jan-23 15:585-Jan-2305-Jan-23 15:1306-Jan-23 11:130.040.83Thu5-Jan-2315:58:00
Project
Cell Formulas
RangeFormula
V2:V34V2=Close-$Z2
W2:W34W2=INDEX(TblTATs[#All],MATCH(D2,TblTATs[[#All],[TAT]],0),MATCH(B2,TblTATs[#Headers],0))/24
X2:X34X2=TEXT(WEEKDAY($G2,1),"Ddd")
Y2:Y34Y2=INT($G2)
Z2:Z34Z2=$G2-INT($G2)
AE7AE7=28*24
AF19AF19=NOW()
AH3:AH28AH3=YEAR(AI3)
AJ3:AJ28AJ3=TEXT(WEEKDAY(AI3,1),"Ddd")
L2:L34L2=IFERROR(IF(OR(D2="A",D2="PT",AND(D2="U",V2>W2)),G2+W2, IF(AND(D2="U",V2<W2),WORKDAY(G2,CEILING(W2,1),HolidayList)+Open+($W2-$V2), IF(AND(B2="FBCT",D2="n/a"),K2+W2, WORKDAY(G2,W2,HolidayList)+Z2))), "Enter due time")
Named Ranges
NameRefers ToCells
Close=Project!$AD$12V2:V34
HolidayList=TblHolidays[Date]L2:L34, AJ3, AH3
Open=Project!$AD$11L2:L34
SType=TblTATs[[#Headers],[BULK]:[PT]]W2:W34
TAT=Project!$AB$3:$AB$8W2:W34
Cells with Data Validation
CellAllowCriteria
G2:H34Datebetween earliest and NOW()
B2:B34List=SType
C2:C34Whole number>=0
D2:D34List=TAT
 
Upvote 0

Forum statistics

Threads
1,223,879
Messages
6,175,145
Members
452,615
Latest member
bogeys2birdies

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