+ Reply to Thread
Results 1 to 6 of 6

Calculate number of business days excluding weekends and holidays?

Hybrid View

  1. #1
    Registered User
    Join Date
    09-03-2007
    Posts
    4

    Calculate number of business days excluding weekends and holidays?

    I have an excel sheet with 3 columns-

    start_date end_date No_of_Workdays
    7-jan-08 14-feb-08
    13-Jan-08 23-feb-08
    15-feb-08 13-Mar-08

    I have to calculate the number of business working days between start_date and end_date in Excal VBA programming.Can anyone tell me the what logic should be used here? If someone had done it earlier , please share the code.
    One thing more,can i use Networkdays() function in a loop.Because i want an automated solution.If some day i change any date ,then the difference should be reflected instantly.
    Last edited by sethi85; 09-06-2007 at 09:23 AM.

  2. #2
    Forum Contributor boylejob's Avatar
    Join Date
    02-22-2007
    Location
    Forest City, NC
    MS-Off Ver
    2003
    Posts
    562
    sethi85,

    I believe you can use the function NETWORKDAYS(M5,D8) out on your worksheet and it should give you the results you are looking for.
    In NETWORKDAYS(M5,D8) M5 would be the starting date and D8 would be the ending date. M5 and D8 are just what happened to be in the sample I copied.
    Sincerely,
    Jeff

  3. #3
    Registered User
    Join Date
    09-03-2007
    Posts
    4
    Thanx a lot for your reply..But i have a list of holidays in sheet2 say for A1-A8..so how would i subtract those values in the Networkdays() function..

  4. #4
    Forum Contributor boylejob's Avatar
    Join Date
    02-22-2007
    Location
    Forest City, NC
    MS-Off Ver
    2003
    Posts
    562
    sethi85,

    I sorry, I went back and read your original post and you obviously already knew about NetWorkDays.

    You might take a look at this thread which is off another Excel forum. The original question seems to have some of the same elements as your problem.

    http://www.ozgrid.com/forum/showthread.php?t=55761

    The last post by BatMan probably has the information you are wanting so as to exclude a list of holidays. Maybe this will get you steered in the right direction.

  5. #5
    Registered User
    Join Date
    08-30-2006
    Posts
    40
    Networkdays can calculate for a list of company holidays as well, here's an example that I use:

    =NETWORKDAYS(E4,$E$1,'Rep Data'!M2:M7)

    I have a list of company holidays on the Rep Data tab from M2-M7, and it excludes those dates from the count.

  6. #6
    Forum Contributor boylejob's Avatar
    Join Date
    02-22-2007
    Location
    Forest City, NC
    MS-Off Ver
    2003
    Posts
    562
    sethi85,

    Thanks Bill-E-Bob! Sometime it is hard to see the forest because of the trees.

    Here is the help on NETWORKDAYS and it definitely looks like you can include the range where you have the holidays listed. I certainly love this list because you learn something new everyday!

    BatMan on the other forum basically suggests the same thing except I believe he names his holiday date range "Holiday" plus he manipulates the worksheet formula using VBA.

    NETWORKDAYS(start_date,end_date,holidays)

    Important Dates should be entered by using the DATE function, or as results of other formulas or functions. For example, use DATE(2008,5,23) for the 23rd day of May, 2008. Problems can occur if dates are entered as text.

    Start_date is a date that represents the start date.

    End_date is a date that represents the end date.

    Holidays is an optional range of one or more dates to exclude from the working calendar, such as state and federal holidays and floating holidays. The list can be either a range of cells that contains the dates or an array constant (array: Used to build single formulas that produce multiple results or that operate on a group of arguments that are arranged in rows and columns. An array range shares a common formula; an array constant is a group of constants used as an argument.) of the serial numbers that represent the dates.

    Remarks

    Microsoft Excel stores dates as sequential serial numbers so they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,448 days after January 1, 1900. Microsoft Excel for the Macintosh uses a different date system as its default.
    If any argument is not a valid date, NETWORKDAYS returns the #VALUE! error value.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1