+ Reply to Thread
Results 1 to 5 of 5

Having trouble determining if a date is a workday or not from VBA

  1. #1
    Forum Contributor
    Join Date
    12-06-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    201

    Having trouble determining if a date is a workday or not from VBA

    I have a future date generated by VBA. I need to test if this date is going to be a valid workday so that I can adjust my date accordingly.

    I also have a range of public holiday dates in a sheet which should also be excluded, same as weekend dates. The Workday function of Excel seems to be the function to use as it can exclude the public holidays as well when these are passed as a range to the function but it doesn't want to tell me if the date is a workday or not. It can tell me what the next workday or the previous workday, from my date, will be but that's not what I need. I need it to tell me the day is a workday or not. Based on this I can then check to see if I want the next working day or previous working day.

    Any input appreciated.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,447

    Re: Having trouble determining if a date is a workday or not from VBA

    Perhaps test with the WEEKDAY function ? If it returns a number >5 it is not a workday ( sorry I'm no good at VBA)

  3. #3
    Forum Contributor
    Join Date
    12-06-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    201

    Re: Having trouble determining if a date is a workday or not from VBA

    The Weekday function will not exclude public holidays. I need them excluded as well.

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,447

    Re: Having trouble determining if a date is a workday or not from VBA

    It will allow you to check the result of the generated future day, although WORKDAY should return a workday as it says

  5. #5
    Forum Contributor
    Join Date
    12-06-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    201

    Re: Having trouble determining if a date is a workday or not from VBA

    Got a resolution. Add one day to the date and then check what the workday before that date will be with the WORKDAY function. Compare the returned date to the date I want to check and voila! If it's the same then the date is a workday.

+ 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: 10
    Last Post: 02-29-2024, 08:55 AM
  2. [SOLVED] need help to lookup a (workday) date, and then excel output to show that date minus 1
    By Marijke in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-23-2013, 11:13 AM
  3. Workday.INTL or Workday function issue
    By junoon in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-17-2013, 03:14 PM
  4. Trouble with Determining Double Values
    By ianternet in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-30-2008, 08:17 PM
  5. [SOLVED] How can I test if a date is a workday?
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-08-2005, 10:06 PM

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