=IF(MOD(TRUNC(K1-J1)+1,7)>MOD(MATCH(G1,{"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"},FALSE)-1-INT(MOD(J1,7))+7,7),1,0)+INT((INT(K1-J1)+1)/7)+IF(MOD(TRUNC(K1-J1)+1,7)>MOD(MATCH(H1,{"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"},FALSE)-1-INT(MOD(J1,7))+7,7),1,0)+INT((INT(K1-J1)+1)/7)+IF(MOD(TRUNC(K1-J1)+1,7)>MOD(MATCH(I1,{"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"},FALSE)-1-INT(MOD(J1,7))+7,7),1,0)+INT((INT(K1-J1)+1)/7)
All in one cell - watch the line breaks. Written for row 1, but can be copied down. I'm sure
Harlan will come up with a much shorter formula - the array formula that I had that was one third
shorter didn't work with blanks, so I gave up on that approach.
HTH,
Bernie
MS Excel MVP
"girlfriend in school" <girlfriendinschool@discussions.microsoft.com> wrote in message
news:C5271A39-23D4-46D5-B3B4-72BD40B4F9E2@microsoft.com...
>I need to count the number of days between a start date and end date and the
> questions about this I found here don't seem to help (boggle me!) I need a
> universal formula that will cover variable days which are listed in a
> separate column:
> G (rows) = names of days; J (rows) = start date; K (rows) = end date. On
> top of this, I am sometimes having to count more than one day (up to three)
> within a week (e.g., Mondays AND Fridays) which I'd be willing to put in
> separate columns (i.e., columns G,H,I) if needed, but if only one column has
> a day listed, the formula needs to ignore the empty columns.
> A knotty problem?
Bookmarks