View Single Post
  #10   Report Post  
Myrna Larson
 
Posts: n/a
Default

IIRC, the OP said that he wants just two weekend days, but they are Friday and
Saturday instead of Saturday and Sunday.

If the start date is in A1 and the end date in B1, and the list of holidays in
a named range Holidays,

=NETWORKDAYS(A1+1,B1+1,Holidays)

will work for this problem. It "tricks" Excel by shifting all dates ahead 1
day of the week, so a "real" Friday is seen as a Saturday by the function (and
hence a day off), and a "real" Sunday is seen as a Monday (and hence a
workday).

Of course you must add 1 to each of the dates in the holiday list, too. That
might be accomplished with a parallel column that adds 1 to the date to the
left. This 2nd column would be used in the calls to the functions involving
workdays.

Or (I haven't tried this), you may be able to use an array formula:

=NETWORKDAYS(A1+1,B1+1,Holidays+1)

Of course if you are dealing with a 4-day workweek, you need VBA or a more
complicated worksheet formula.



On Tue, 1 Mar 2005 11:03:43 -0000, "Bob Phillips"
wrote:

It will have problems with the holidays as well as the startdate is after
the enddate. I must admit I have never liked the fact that NETWORKDAYS
returns negatives, so here is another version. It doesn't return the same as
NETWORKDAYS because it doesn't return negative number of days, so it is
agnostic as to whether C1 is the start or end date, which is how it should
be IMO. If a negative sign is wanted, it could be added.

=SUMPRODUCT(INT((MAX(C1,E1)-WEEKDAY(MAX(C1,E1)+1-{2;3;4;5;6})-MIN(C1,E1)+8)/
7))-SUMPRODUCT(ISNUMBER(MATCH(WEEKDAY(holidays),{2;3;4 ;5;6},0))*(holidays=M
IN(C1,E1))*(holidays<=MAX(C1,E1)))