+ Reply to Thread
Results 1 to 13 of 13

Exclude Weekends in formula

Hybrid View

  1. #1
    Registered User
    Join Date
    05-31-2016
    Location
    South Africa
    MS-Off Ver
    2010
    Posts
    6

    Exclude Weekends in formula

    Hi

    How do I exclude weekends on the following conditional formatting formula:
    =IF(F4-B4<=7,TRUE). F4 and B4 are the two columns with dates in.

    Thanks

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,478

    Re: Exclude Weekends in formula

    Have you explored the NETWORKDAYS() function?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    05-31-2016
    Location
    South Africa
    MS-Off Ver
    2010
    Posts
    6

    Re: Exclude Weekends in formula

    Hi Ali

    I tried, it didn't work. I am not sure where exactly to put it. Will you please assist me.

    Thanks

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,478

    Re: Exclude Weekends in formula

    If you can provide a workbook for me, yes, I'll try.

    EDIT Try this:

    =IF(NETWORKDAYS(F4,B4)<=7,TRUE)
    Last edited by AliGW; 06-02-2016 at 07:18 AM.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Exclude Weekends in formula

    Maybe this...

    =NETWORKDAYS(B4,F4)<=7
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    05-31-2016
    Location
    South Africa
    MS-Off Ver
    2010
    Posts
    6

    Re: Exclude Weekends in formula

    Hi Ali & Tony

    Thanks.

    I tried =NETWORKDAYS(B4,F4)<=7 and it seems to work however it seems to ignore the times as well. For example if an incident is captured @13h00 on 30 May, 7 days is on 8 June @13h00 (excluding weekends), therefore anything after 13h00 on 8 June is over 7 days, hence it should be red.

    Please check the conditional formatting in column F, that is the one I have updated with the formula you suggested.

    Thanks
    Attached Files Attached Files

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,478

    Re: Exclude Weekends in formula

    This has moved quite a way from what you asked for at the beginning! I'm afraid I'll have to bow out on this one: dates and times in Excel are not my strong point, sorry!

  8. #8
    Registered User
    Join Date
    05-31-2016
    Location
    South Africa
    MS-Off Ver
    2010
    Posts
    6

    Re: Exclude Weekends in formula

    Thanks for your help Ali. Apologies for not being specific enough.

  9. #9
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Exclude Weekends in formula

    Try

    =AND(NETWORKDAYS(B4,F4)<=7,MOD(B4,1)>=MOD(F4,1))

    Checks that the difference is less than 7 working days, and that the time in F4 is earlier than the time in B4.

  10. #10
    Registered User
    Join Date
    05-31-2016
    Location
    South Africa
    MS-Off Ver
    2010
    Posts
    6

    Re: Exclude Weekends in formula

    Thanks Jason.

    The formula works however after 12pm it doesn't. Any ideas why its doing that?

  11. #11
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Exclude Weekends in formula

    Not sure what I was thinking with that formula, it looked good at the time. It fails when the time in B4 is earlier than the time in F4 and the difference in days excluding the time part is less than 7.

    This one is better

    =(NETWORKDAYS(B4,F4)+MOD(B4,1)-MOD(F4,1))<7

  12. #12
    Registered User
    Join Date
    05-31-2016
    Location
    South Africa
    MS-Off Ver
    2010
    Posts
    6

    Re: Exclude Weekends in formula

    Hi Jason

    Thanks. I am however not sure what it is I am doing wrong. Please check the conditional formatting rules in column F (I have attached the file). What I am trying to do is conditional format the cell green if the date and time is less than 7 days, amber if it is 8 days and red if it is 9 days (the date I am comparing to is in column B).

    Please help.
    Attached Files Attached Files

  13. #13
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Exclude Weekends in formula

    That worksheet still has the formula from post #9 in the conditional formatting, you need to update it to the formula in post #11 for it to work.

    That formula is for the green condition, change <7 to <9 for yellow, and >=9 for red.

    The 'Stop if true' boxes all need to be checked.

+ 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. [SOLVED] Formula to Exclude Holiday but not weekends
    By nested.if1@gmail.com in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-03-2015, 12:35 PM
  2. Formula to Exclude weekends ( Saturday and Sunday )
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-21-2014, 04:24 AM
  3. Replies: 6
    Last Post: 10-16-2013, 09:58 AM
  4. Formula to exclude weekends-that will calculate the due date
    By ieatbred in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-16-2011, 06:46 PM
  5. Exclude weekends and holidays from a formula.
    By Stevey in forum Excel General
    Replies: 5
    Last Post: 08-28-2009, 06:55 PM
  6. Formula to exclude weekends
    By bton24 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-11-2006, 06:00 PM
  7. calculation to exclude weekends
    By Need2Know in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM

Tags for this Thread

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