+ Reply to Thread
Results 1 to 5 of 5

How to show only Working Day on expire date (Friday + 2 = Tuesday)

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    66

    How to show only Working Day on expire date (Friday + 2 = Tuesday)

    Hi,

    I have a code which will show the today date and expire date in msgbox by click the button in attach excel file (and the code was show below ).
    But how to make msgbox show only working day at expire date?

    Example,
    Today date: now (assume to be Friday).
    By adding 2 to today date, the expire date will show on Sunday.

    Prefer (How to
    By adding 2 to today date, the expire date will show on Tuesday (instate of Sunday).



    PHP Code: 
    Sub adding()

    Dim idate As String
    Dim result 
    As String


    idate 
    Now
    result 
    Now 2

    MsgBox 
    "Today date: " Format(Now"dddd, dd / mmm / yy") & vbNewLine _
                        
    "Expired date: " Format(result"dddd, dd / mmm / yy")


    End Sub 
    BR
    KC
    Attached Files Attached Files

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: How to show only Working Day on expire date (Friday + 2 = Tuesday)

    Try this....

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: How to show only Working Day on expire date (Friday + 2 = Tuesday)

    or you can use the WORKDAY function.

  4. #4
    Registered User
    Join Date
    11-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: How to show only Working Day on expire date (Friday + 2 = Tuesday)

    Hi Sixthsense and nathansav,

    Both your methods is work. I have join up / modified the codes to suit my need.
    By adding another criteria:
    1) dtExpired = worksheetfunction.workday(now,x)
    2) x = activesheet.cells(10,5)

    The expired date will showing working day (and during generating the expired date, it will skip through all the weekend and give more accurate ending/expired date)


    PHP Code: 
    Sub adding()

    Dim x As String
    Dim dtExpired 
    As String

    ActiveSheet.Cells(105)

    dtExpired WorksheetFunction.WorkDay(Nowx)

    Select Case Format(Date"dddd")
        Case 
    Is "Sunday"
            
    dtExpired dtExpired 1
        
    Case Is "Saturday"
            
    dtExpired dtExpired 2
    End Select

    MsgBox 
    "Today date: " Format(Now"dddd, dd / mmm / yy") & vbNewLine _
            
    "Expired date: " Format(dtExpired"dddd, dd / mmm / yy")

    End Sub 
    What if my working day is 6 days? How to teach the workday to recognize saturday belong to working day?

    BR
    KC
    Attached Files Attached Files
    Last edited by alexnkc; 02-19-2013 at 07:24 AM. Reason: Include Attachment excel file

  5. #5
    Registered User
    Join Date
    11-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: How to show only Working Day on expire date (Friday + 2 = Tuesday)

    Hi,

    Any idea??

    BR
    KC

+ 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