+ Reply to Thread
Results 1 to 10 of 10

Return value to a weekday closest to certain date

  1. #1
    Registered User
    Join Date
    07-10-2018
    Location
    Uk
    MS-Off Ver
    MS365 Version 2102
    Posts
    86

    Return value to a weekday closest to certain date

    Hi,

    I’m trying to return salary (from one cell) in to a cell next to the 28th (calendar as list) or Friday prior to the 28th if the 28th falls on weekend or bank holiday. Any help greatly appreciated.

    Thanks

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

    Re: Return value to a weekday closest to certain date

    Welcome to the forum!

    We can't guess your layout, so please attach a sample workbook.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    06-25-2018
    Location
    Madrid, Spain
    MS-Off Ver
    2013
    Posts
    92

    Re: Return value to a weekday closest to certain date

    You could use the formula weekday to get the day of the week it corresponds to. Combine it with an IF statement to make sure you get a Friday, but, as Ali mentioned, without a file or something to go by it will be pretty hard to know exactly what you need.

  4. #4
    Registered User
    Join Date
    07-10-2018
    Location
    Uk
    MS-Off Ver
    MS365 Version 2102
    Posts
    86

    Re: Return value to a weekday closest to certain date

    Sorry about my first post please see the attached file.

    Basically I would like a formula that I could put in D1 then auto fill down to the bottom of the date range.

    I need the formula to pick up cell a6 IF it’s the 28th AND also if the 28th falls on a weekend then move the cell to the Friday prior to the weekend?

    Many thanks for any help
    Attached Files Attached Files

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,237

    Re: Return value to a weekday closest to certain date

    See if you can adapt the formulae here to do what you want:

    Excel 2016 (Windows) 32 bit
    C
    D
    E
    F
    G
    1
    10 July 2018
    4
    0
    10
    2
    11 July 2018
    5
    0
    11
    3
    12 July 2018
    6
    0
    12
    4
    13 July 2018
    7
    0
    13
    5
    14 July 2018
    1
    0
    14
    6
    15 July 2018
    2
    0
    15
    7
    16 July 2018
    3
    0
    16
    8
    17 July 2018
    4
    0
    17
    9
    18 July 2018
    5
    0
    18
    10
    19 July 2018
    6
    0
    19
    11
    20 July 2018
    7
    0
    20
    12
    21 July 2018
    1
    0
    21
    13
    22 July 2018
    2
    0
    22
    14
    23 July 2018
    3
    0
    23
    15
    24 July 2018
    4
    0
    24
    16
    25 July 2018
    5
    0
    25
    17
    26 July 2018
    6
    0
    26
    18
    27 July 2018
    Salary here
    7
    1
    27
    19
    28 July 2018
    1
    0
    28
    20
    29 July 2018
    2
    0
    29
    21
    30 July 2018
    3
    0
    30
    22
    31 July 2018
    4
    0
    31
    23
    01 August 2018
    5
    0
    1
    24
    02 August 2018
    6
    0
    2
    25
    03 August 2018
    7
    0
    3
    26
    04 August 2018
    1
    0
    4
    27
    05 August 2018
    2
    0
    5
    28
    06 August 2018
    3
    0
    6
    29
    07 August 2018
    4
    0
    7
    30
    08 August 2018
    5
    0
    8
    31
    09 August 2018
    6
    0
    9
    Sheet: Sheet1

    Excel 2016 (Windows) 32 bit
    E
    F
    G
    1
    =WEEKDAY(C1,16)
    =IF(AND(G1=28,E1>2),1,IF(AND(E1=7,OR(G1=26,G1=27)),1,0))
    =DAY(C1)
    Sheet: Sheet1

  6. #6
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,915

    Re: Return value to a weekday closest to certain date

    Try this in D1:

    =IF(WORKDAY(C1-DAY(C1)+29,-1,holidays)=C1,"Salary here","")

  7. #7
    Registered User
    Join Date
    07-10-2018
    Location
    Uk
    MS-Off Ver
    MS365 Version 2102
    Posts
    86

    Re: Return value to a weekday closest to certain date

    Hi,


    This has been a big help,

    Would it be possible to change column F from showing 1 when its on the 28th and instead show cell A6 (in the test sheet I posted earlier)?

    Many Thanks

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,237

    Re: Return value to a weekday closest to certain date

    Yes, like this:

    =IF(AND(G1=28,E1>2),$A$6,IF(AND(E1=7,OR(G1=26,G1=27)),$A$6,0))

    So, your composite formula would be:

    =IF(AND(DAY(C1)=28,WEEKDAY(C1,16)>2),$A$6,IF(AND(WEEKDAY(C1,16)=7,OR(DAY(C1)=26,DAY(C1)=27)),$A$6,0))

    I am presuming you were replying to me.

  9. #9
    Registered User
    Join Date
    07-10-2018
    Location
    Uk
    MS-Off Ver
    MS365 Version 2102
    Posts
    86

    Re: Return value to a weekday closest to certain date

    Thanks a lot for your help Ali.

    All working as it should be!

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,237

    Re: Return value to a weekday closest to certain date

    Glad to have helped!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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 get weekday closest to 20th of the month
    By rizmomin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-20-2018, 06:32 PM
  2. Replies: 6
    Last Post: 11-02-2016, 09:54 AM
  3. Excel VBA code to return weekday name from a date then autofilters for userdefined weekday
    By studyengineering in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2016, 03:24 PM
  4. [SOLVED] Calculate weekday end date based on sum of weekday start date and cell value
    By Rerock in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-01-2014, 09:17 AM
  5. Return value based on closest time/date and name
    By Steven87 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-11-2013, 03:52 PM
  6. Return date for the next coming weekday
    By ElmerS in forum Excel General
    Replies: 7
    Last Post: 05-24-2010, 12:51 PM
  7. Add a number to date and return a weekday
    By dwain in forum Excel General
    Replies: 3
    Last Post: 10-13-2008, 10:55 AM

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