Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jun 2003
    Location
    london, Gtr London, England
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel VBA - NetworkDays (Excel VBA)

    I would like to write a function to calculate the number of working days between two dates (including the time component of the date). Note that the Excel NETWORKDAYS function does not account for the time component. My initial plan was to write a function which used the Excel NETWORKDAYS function, however this does not appear to be available in VBA ?

    Is there a way of calculating the number of working days between two dates including the time component in Excel VBA ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Excel VBA - NetworkDays (Excel VBA)

    You can install the 'Analysis Toolpak - VBA' add-in (Tools | Add-Ins...), then set a reference in the Visual Basic Editor to the 'atpvbaen.xls' library (Tools | References...). This will make the Networkdays function available in VBA, along with many other functions from the Analysis Toolpak.

    I'm not sure what you want to do with the time component.

  3. #3
    New Lounger
    Join Date
    Jun 2003
    Location
    london, Gtr London, England
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel VBA - NetworkDays (Excel VBA)

    Thanks very much that is a big help.

    In relation to the time component, I wanted to calculate the interval between two dates and times, excluding weekends. For example:

    16-Aug-04 09:00 and 18-Aug-04 21:00 = 2.5 days
    13-Aug-04 09:00 and 18-Aug-04 21:00 = 3.5 days (excluding 2 days for weekends)
    14-Aug-04 09:00 and 18-Aug-04 21:00 = 2.875 days (again 14th and 15th are weekends and are excluded)

    If you know way of doing this that would be helpful, otherwise I could write a function myself.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Excel VBA - NetworkDays (Excel VBA)

    Does the attached (somewhat clunky) function do what you want?

Posting Permissions

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