View Single Post
  #2   Report Post  
Jason Morin
 
Posts: n/a
Default

Try:

=NETWORKDAYS(A1,B1,J1:J10)-2+(1-MOD(A1,1))+MOD(B1,1)

where J1:J10 is your list of holiday dates, A1 is the
start date/time, and B1 is the end date/time. You can
simplify the formula further using:

=NETWORKDAYS(A1,B1,J1:J10)-1-MOD(A1,1)+MOD(B1,1)

Make sure the analysis toolpak is installed under Tools
Add-Ins. Otherwise you'll get a #NAME? error.

HTH
Jason
Atlanta, GA


-----Original Message-----
I have no idea where I've gone wrong. Given the

following
cells:

J13= Start Date & Time
K13=End Date & Time
AE66:AE83=Range of non-working holidays
H5= Start of workday (a time)
H6=End of workday (also a time)

I've evolved (with a lot of help) the followng formula.
It is supposed to return the number of workdays and
workhours between the start date and time and the end
date and time. Much of the time it works pretty well,

but
too often I'm getting negative hour counts. I have no
idea where I've gone wrong. HELP! I'm desperate and
tired. Here's the formula:

=IF(AND(INT(J13)=INT(K13),NOT(ISNA(MATCH(INT(J13) ,
AE66:AE83,0)))),"0 days 0 hours", IF(INT(J13)=INT(K13),
"0 days " & ROUND(24*(K13-J13),2)&"hours",
MAX(NETWORKDAYS(J13+1,K13-1,AE66:AE83),0)+
INT(24*(((K13-INT(K13))-(J13-INT(J13)))+
('H6'-H5))/(24*('H6'-H5)))&
" days "&MOD(ROUND(((24*(K13-INT(K13)))-24*H5)+
(24*'H6'-(24*(J13-INT(J13)))),2),
ROUND((24*('H6'-H5)),2))&" hours "))

Does anyone know how I can rewrite this to make it
consistent? All I need is, for a wide variety of
starting and ending dates/times, to calculate the number
of workdays and workhours between the two.
.