+ Reply to Thread
Results 1 to 16 of 16

Calculating Weeks, Weekday nights and Weekend nights

Hybrid View

  1. #1
    Registered User
    Join Date
    10-20-2010
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Calculating wkday nights and wkend nights

    Quote Originally Posted by DonkeyOte View Post
    From what I can tell the Demo works, no ?

    (NETWORKDAYS.INTL is exclusive to XL2010 and beyond)
    Ok but you get an idea of what i'm trying to do, i have a check-in date and check-out date, using these two dates i need to find out the number of weekday nights(SUN-THU) and number of weekend Nights(FRI-SAT).

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Calculating wkday nights and wkend nights

    Perhaps you could explain how the sample you posted isn't doing what you want because to me it seems to do exactly as you requested.

  3. #3
    Registered User
    Join Date
    10-20-2010
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Calculating wkday nights and wkend nights

    Quote Originally Posted by DonkeyOte View Post
    Perhaps you could explain how the sample you posted isn't doing what you want because to me it seems to do exactly as you requested.
    Lets say somebody checks in on Sunday morning and checks out on Friday Morning,the number of weekday nights should be 5 and weekend nights should be zero.
    With the formula i used i get number of weekday nights to be 4 and number of weekend nights to be 1.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Calculating wkday nights and wkend nights

    Ah, sorry - yes I see !

    =MAX(0,NETWORKDAYS.INTL(B2,C2-1,7))
    the above discounts check out date - the MAX should prove superfluous but you never know...

  5. #5
    Registered User
    Join Date
    10-20-2010
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Calculating wkday nights and wkend nights

    the above discounts check out date - the MAX should prove superfluous but you never know...[/QUOTE]

    Thanks that works well, i have another question though, is it possible to set check in and check out dates to Today() as default.
    Last edited by DonkeyOte; 10-26-2010 at 02:13 AM. Reason: unnec. quote removed

  6. #6
    Registered User
    Join Date
    10-20-2010
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Calculating number of weeks, weekday nights & weekend nights

    Thanks that works well, i have to add another column that computes the number of weeks between 2 dates.Please See Demo.
    Attached Files Attached Files
    Last edited by DonkeyOte; 10-26-2010 at 02:14 AM. Reason: unnec. quote removed

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Calculating Weeks, Weekday nights and Weekend nights

    No need to quote prior posts in their entirety in your reply - this just clutters the board.

    I confess that again I am a little confused by the example

    Check-In 7-Oct
    Check-Out 28-Oct
    is 21 nights so why is the expected results anything other than 3 weeks ?

    Were

    Check-Out 27-Oct
    then I concur with 2 weeks, 4 weekday and 2 weekend:

    D2:
    =MAX(0,NETWORKDAYS.INTL(B2+(F2*7),C2-1,7))
    
    E2:
    =C2-B2-(F2*7)-D2
    
    F2:
    =MAX(0,INT(C2-B2/7))

  8. #8
    Registered User
    Join Date
    10-20-2010
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Calculating Weeks, Weekday nights and Weekend nights

    Thanks i had already solved that one before you posted,now my last task is to have a message popup whenever the stay is exceeded by 3 weeks.I would really appreciate if you could help me out with this one:

    If ((F2>3) OR ((F2 = 3) AND ((E2 >1) OR (D2>1)))) then
    MsgBox (" Stay Cannot Exceed 3 Weeks !!! ")
    End if

    Except F2,E2,D2 are all columns with 54 rows, so when the user enters the check-in date and check-out date, D2 , E2 , F2 are computed and the macro should immediately alert the user if the above conditions are met.I'm really new to VBA, if you could code the macro for me that would be great.

    Thanks
    Last edited by bngguy; 10-26-2010 at 03:32 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