+ Reply to Thread
Results 1 to 8 of 8

Determine Last working day of Month

  1. #1
    Nigel
    Guest

    Determine Last working day of Month

    Is there any way to determine the last working day of a month by using code

    Thanks

  2. #2
    Bob Phillips
    Guest

    Re: Determine Last working day of Month

    =DATE(YEAR(A6),MONTH(A6)+1,0)-(WEEKDAY(DATE(YEAR(A6),MONTH(A6)+1,0),2)>5)-(W
    EEKDAY(DATE(YEAR(A6),MONTH(A6)+1,0),2)=7)

    --
    HTH

    Bob Phillips

    (remove xxx from email address if mailing direct)

    "Nigel" <[email protected]> wrote in message
    news:[email protected]...
    > Is there any way to determine the last working day of a month by using

    code
    >
    > Thanks




  3. #3
    Ivan Raiminius
    Guest

    Re: Determine Last working day of Month

    Hi Nigel,

    supposing that Input_Date is a date:

    (Int(CDbl(Input_Date)) - 1) Mod 7 = 6 'saturday
    (Int(CDbl(Input_Date)) - 1) Mod 7 = 0 'sunday

    Did it help?

    Regards,
    Ivan


  4. #4
    Tom Ogilvy
    Guest

    RE: Determine Last working day of Month

    Dim dt as Date
    Dim dtLastDay as Date
    dt = date
    dtLastDay = DateSerial(year(dt),month(dt)+1,0)
    if Weekday(dtLastDay,vbMonday) > 5 then
    dtlast = dtLastDay - (Weekday(dtLastDay,vbMonday) - 5)
    ' consider holidays?
    end if

    --
    Regards,
    Tom Ogilvy

    "Nigel" wrote:

    > Is there any way to determine the last working day of a month by using code
    >
    > Thanks


  5. #5

    Re: Determine Last working day of Month

    Probably pre-empting the original question, but the request was for
    last working day of a month - the code that has been given gives the
    last weekday of the month (ie Monday through Friday) - what about if
    that day is a public or other holiday - that would need to be
    incorporated which would make the project a little more complicated! I
    have done it in Access, with a table for holidays, and there are
    functions in excel we could use, but not sure about "IN CODE"


  6. #6
    Thrashman
    Guest

    RE: Determine Last working day of Month

    I'm not sure precisely how to work this in - but you can use the
    =workday(a,b,c) function in the analysis tookpak to help with this (there is
    also a vba version)

    a = start date
    b = number of working days to count
    c = range with a list of holidays (or the list itself I guess).
    this will avoid weekends as well as the list of holidays.
    haven't thought it out on how to use this - this function is also available
    to a VBA routine - however I'm not sure how to get one add-in to call a
    routien in another add-in - I have a question pending on that myself - hope
    this helps


    "Nigel" wrote:

    > Is there any way to determine the last working day of a month by using code
    >
    > Thanks


  7. #7
    Registered User
    Join Date
    10-21-2012
    Location
    Yorktown, VA
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Determine Last working day of Month

    Quote Originally Posted by Tom Ogilvy View Post
    Dim dt as Date
    Dim dtLastDay as Date
    dt = date
    dtLastDay = DateSerial(year(dt),month(dt)+1,0)
    if Weekday(dtLastDay,vbMonday) > 5 then
    dtlast = dtLastDay - (Weekday(dtLastDay,vbMonday) - 5)
    ' consider holidays?
    end if

    --
    Regards,
    Tom Ogilvy

    "Nigel" wrote:

    > Is there any way to determine the last working day of a month by using code
    >
    > Thanks
    This does not work for the dt= "12/01/1970" (and, perhaps other years).

    Is there something that I am missing?

    Thanks in advance for any help.

    Hokie

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Determine Last working day of Month

    Hokie,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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