+ Reply to Thread
Results 1 to 8 of 8

Effective Days function in VBA

  1. #1
    Registered User
    Join Date
    05-07-2009
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2003
    Posts
    34

    Effective Days function in VBA

    Hi all,

    I am after a piece of coding to incorporate into a user defined function as follows:

    =UDF(start_date , finish_date , [1 or 2 or 3] , 'range of public holiday dates')

    1 = calendar days (i.e. finish_date - start_date)
    2 = business days (i.e. finish_date - start_date, less weekends and public holidays)
    3 = working days (i.e. finish_date - start_date, less Sundays and public holidays)

    This is similar to the 'NETWORKDAYS.INTL' standard function, however I cannot use that for two reasons; first the standard 'NETWORKDAYS.INTL' function does not calculate calendar days, and second I need the coding to be part of a larger user defined function that already has a start_date and finish_date field in it.

    Any help would be appreciated.

    Thanks.
    Last edited by M@N; 06-15-2016 at 02:02 AM. Reason: Solved

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Effective Days function in VBA

    Maybe :

    Please Login or Register  to view this content.
    Attached Files Attached Files
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  3. #3
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Effective Days function in VBA

    Here's another version

    Just check that Karedogs version doesn't count public holidays that also fall on a weekend. These need to be excluded from the count as they overlap.

    Please Login or Register  to view this content.
    Happy with my advice? Click on the * reputation button below

  4. #4
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Effective Days function in VBA

    And here's the file with the UDF
    Attached Files Attached Files

  5. #5
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Effective Days function in VBA

    Good catch Crooza, I miss that point.

    Fixed UDF :
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-07-2009
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Effective Days function in VBA

    Karedog /Crooza, thank you both. Works a treat!

  7. #7
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Effective Days function in VBA

    Great. Glad it works how you wanted

  8. #8
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Effective Days function in VBA

    You are welcome M@N, thanks for the rep. points and marking the thread as solved.


    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 13
    Last Post: 09-22-2016, 09:18 AM
  2. [SOLVED] More effective rank function
    By adandsar in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-02-2015, 04:52 PM
  3. DAYS function: correctly calculating the number of days
    By dadpad in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-25-2015, 09:18 PM
  4. Replies: 4
    Last Post: 04-10-2013, 02:37 AM
  5. SUMIF Function if within 30 days, 60 days, etc
    By Geomin3 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-25-2013, 05:39 AM
  6. Replies: 5
    Last Post: 03-22-2012, 04:51 AM
  7. [SOLVED] Effective interest paid - need formula/function
    By Pasko1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-18-2005, 05:02 PM

Tags for this Thread

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