Selected Answer
You are in luck! There is a great formula for this.
=WORKDAY(A2,INT(B2/8)+IF(TIME(HOUR(A2),MINUTE(A2),SECOND(A2))+TIME(MOD(B2,8),MOD(MOD(B2,8),1)*60,0)>
$F$2,1,0))+IF(TIME(HOUR(A2),MINUTE(A2),SECOND(A2))+TIME(MOD(B2,8),MOD(MOD(B2,8),1)*60,0)>$F$2,$E$2
+TIME(HOUR(A2),MINUTE(A2),SECOND(A2))+TIME(MOD(B2,8),MOD(MOD(B2,8),1)*60,0)-$F$2,TIME(HOUR(A2),MINUTE(A2),SECOND(A2))
+TIME(MOD(B2,8),MOD(MOD(B2,8),1)*60,0))
In this example it is assumed that you have 4 cells setup like this:
- A2 is the starting date/time
- B2 is the number of hours
- E2 is the starting time of the workday
- F2 is the ending time of the workday
You can change the cell references as you need but be careful since it's a huge formula and you will need to change things in a few different places.
(I found this formula on the web a while back and it has worked great for me.)