Dynamic Date Count

Staggers72

New Member
Joined
Feb 16, 2011
Messages
3
Hey I need to create a spreadsheet that will count days between start date and todays date with the following stipulations:

1.) Need to exclude sundays
2.) Need to exclude holidays

and the one that is giving me fits...
3.) exclude non workdays ..... these are days that we don't work because of weather and other reasons, like we don't want to work on a particular saturday but some saturdays we do....

Networkdays works well , because you simple add days to the 'holiday list' and they will not be counted. You can also correct the Networkdays counting of only weekdays by adding the number saturdays to the day count.....BUT not all saturdays are work days....hence my problem...

Below is my list of formulas

=SUM(IF(ISERROR(MATCH(WEEKDAY(ROW(INDIRECT(D6&":"&C6))),{1},0)),1,0))
returns the number of days minus sunday

=NETWORKDAYS(D6,C6,'Days Worked Lists'!I5:I35)+J6
returns the number of days minus holidays and adds back saturdays

=SUM(IF(ISERROR(MATCH(WEEKDAY(ROW(INDIRECT(D6&":"&C6))),{1,2,3,4,5,6},0)),1,0))
returns the number of saturdays in the date range....as you can see this is an array formula. This formula is represented by "J6" in above formula and I think is the problem, because when I add a Saturday to the Holiday/nonworkdays list, it is not recognized and therefore is counted.

=SUMPRODUCT(N(WEEKDAY(ROW(INDIRECT(D6&":"&C6)))<>1))
another way of counting days minus sunday....easier to follow


This is what I think is happening....the formula represented by J6, which is an array, overides the holiday list of networkdays.....because what I was doing was adding in the saturdays that we dont work....

I need this spreedsheet to work for someone that can only enter date into excel....

I know I am rambling but I want to give everyone all the info, because I think this is something that others would really like to use. So in summary , I want a spread sheet that you enter a start date and holidays and non workdays and the end result is the number of days worked from a start date and todays date or end date.......the list of holidays and non work days needs to be added to on a regular basis. And the catch, some saturdays we work and some we don't.

Please help
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Think I got it working.

Columns D,F,H are combined in J and checked against Column K the NETWORKDAYS.INTL Function which can specify the weekend but not available prior to Excel 2010.

D2 is just NETWORKDAYS function
F2 Counts the Saturdays over the range of dates. (credit to Chip Pearson [1]) To be added to NETWORKDAYS (D2)
H2 Counts the holidays that fall on Saturdays and are between the start and end date. This is to count the holidays that are exclude in the NETWORKDAYS function. To be subtracted from NETWORKDAYS(D2)
Excel Workbook
ABCDEFGHIJK
1StartEndHoldaysNETWORKDAY+Total Saturdays-Holidays & Saturday=CombinedNETWORKDAYS.INTL
27/7/20076/16/2011Thu - 6/21/071018206312211221
3Sun - 8/17/08
4Sun - 8/17/08
5Fri - 11/21/08
6Thu - 1/8/09
7Wed - 2/25/09
8Tue - 4/14/09
9Mon - 6/1/09
10Sun - 7/19/09
11Sat - 9/5/09
12Fri - 10/23/09
13Thu - 12/10/09
14Wed - 1/27/10
15Tue - 3/16/10
16Mon - 5/3/10
17Sun - 6/20/10
18Sat - 8/7/10
19Fri - 9/24/10
20Sat - 9/25/10
...
Excel 2010
Cell Formulas
RangeFormula
B2=TODAY()
D2=NETWORKDAYS(A2,B2,C2:C20)
K2=NETWORKDAYS.INTL(A2,B2,11,C2:C20)
#VALUE!
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.

I also wrote a user defined function in VBA which reproduce the functionality of NETWORKDAYS.INTL (see this thread, if interested)
 
Last edited:
Upvote 0
Here's a simpler formula for counting Sundays between C6 and D6

=INT((WEEKDAY(C6-1)+D6-C6)/7)

so to get a count of all days except Sundays you can use this

=D6-C6+1-INT((WEEKDAY(C6-1)+D6-C6)/7)

Then subtract all the non-Sunday holidays/non working days, i.e.

=D6-C6+1-INT((WEEKDAY(C6-1)+D6-C6)/7)-SUMPRODUCT((Y2:Z100>=C6)*(Y2:Z100<=D6)*(WEEKDAY(Y2:Z100)<>1))

assumes you have holidays in Y2:Y100 and other non-working days in Z2:Z100
 
Upvote 0
the issue with both of these fixes is that they do not allow one to 'add' dates to the list, without having to know how to deal with an array.

Another way to look at is like this....say you are setting this up to start at the beginning of the year, you won't know which days during the year you will not work because of weather and or other issues. So their needs to be a list, that will have blank cells for someone else to enter in the non work days.

Each of these fixes, does not allow for input into the list....

So how do we do that....
 
Upvote 0
Okay I figured it out using Barry's solution....thanks very much...now I have a spread sheet that any non work day (in the future) can be added to a defined list....AWESOME....
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,750
Members
452,940
Latest member
rootytrip

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