+ Reply to Thread
Results 1 to 6 of 6

Skip a day of the week

Hybrid View

Darbar Skip a day of the week 05-24-2005, 03:57 AM
Flintstone Hi Darbar: This is the... 05-25-2005, 04:21 PM
mangesh_yadav Use the following function.... 05-27-2005, 08:02 AM
Darbar Thank you 05-30-2005, 04:33 AM
mangesh_yadav Appreciate the feedback.... 05-30-2005, 05:30 AM
mangesh_yadav Found another solution... 06-06-2005, 09:31 AM
  1. #1
    Registered User
    Join Date
    05-24-2005
    Posts
    2

    Question Skip a day of the week

    Hi All,

    I have a situation like I need to skip Thursday(weekly off) from weekdays(sat & sunday are included). For example :


    Today is 24 May 2005 and if I add 4 to this date, it will give 28 May 2005. But in this I have one Thursday, it should ignore Thursday and I need a result like 29 May.

    Clear explanation of my query


    Say if cell A1 is having todays date and A2 is having number 4 then I need the specified result in cell C1. And the result should not include Thursdays.

    Can anyone please help me regarding this issue.

    Thanks in Advance

    Darbar
    Last edited by Darbar; 05-24-2005 at 06:01 AM. Reason: To give clear explanation

  2. #2
    Forum Contributor
    Join Date
    10-14-2004
    Location
    San Diego, CA
    Posts
    213
    Hi Darbar:

    This is the best I could come up with; I hope its good enough.

    =IF(A2+WEEKDAY(A1,1)=5,A2+A1+1,A2+A1)

    Or

    =IF(A2+WEEKDAY(A1)=1,A1+A2,IF(A2+WEEKDAY(A1)=2,A1+A2,IF(A2+WEEKDAY(A1)=3,A1+A2,IF(A2+WEEKDAY(A1)=4,A1+A2,IF(A2+WEEKDAY(A1)=5,A1+A2+1,IF(A2+WEEKDAY(A1)=6,A1+A2,IF(A2+WEEKDAY(A1)=12,A1+A2,"")))))))

    Place either, or in C1.

    The formulas work like you requested, "skipping over Thursday".

    Formulas only work for the first Thursday, that means A2 should not be a number greater than 6.

    Problem is you can't remove Thursday's from the calendar, and the date functions won’t allow you to ignore them either. Or more to the fact is that I just don't have enough know how to get around it.

    Matt

  3. #3
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    Use the following function. Enter the following code in a standard module:

    Function myWorkDay(myDate As Date, AddDays, LeaveDay)
    
        If AddDays = 0 Then
            myWorkDay = myDate
            Exit Function
        End If
    
        For j = 1 To 7
            If Choose(j, "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") = LeaveDay Then
                LD = j
            End If
        Next j
    
        i = 1
        Do While i <= AddDays
            myWorkDay = myDate + i
            If WorksheetFunction.Weekday(myWorkDay) = LD Then
                AddDays = AddDays + 1
            End If
            i = i + 1
        Loop
    
    End Function
    Usage:
    Enter in cell C1
    =myWorkDay(A1,A2,"Thursday")


    Mangesh

  4. #4
    Registered User
    Join Date
    05-24-2005
    Posts
    2

    Thumbs up Thank you

    Thank you very much Mangesh !!!!

    I got the perfect result. Thanks a lot.


    DARBAR

  5. #5
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    Appreciate the feedback. Thanks

    Mangesh

  6. #6
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    Found another solution through this thread:
    http://excelforum.com/showthread.php...d=1#post992503

    =$A$1+IF(B1=0,0,SIGN(B1)*SMALL(IF((WEEKDAY($A$1+SIGN(B1)*(ROW(INDIRECT("1:"&ABS(B1)*10))),2)<>4)*ISNA(MATCH($A$1+SIGN(B1)*(ROW(INDIRECT("1:"&ABS(B1)*10))),0,0)),ROW(INDIRECT("1:"&ABS(B1)*10))),ABS(B1)))

    confirm with control shift enter

    A1 is the date, B1 is the number of days to add.



    Mangesh
    Last edited by mangesh_yadav; 06-06-2005 at 09:38 AM.

+ 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