+ Reply to Thread
Results 1 to 5 of 5

If yesterday is a Sunday return Fridays date otherwise Return yesterdays date

  1. #1
    Registered User
    Join Date
    02-04-2018
    Location
    Canberra, Australia
    MS-Off Ver
    2013
    Posts
    74

    If yesterday is a Sunday return Fridays date otherwise Return yesterdays date

    Hi All,

    I need to open a file with yesterdays date except on a Monday when I need to open the Friday file.

    I have the following code that opens last Sundays but not sure how to manipulate it to return Friday date when it today is Monday.

    My original code is Sub Test2 which returns yesterdays date but I forgot we don't produce files on the weekend.

    Please Login or Register  to view this content.
    [/CODE]

    Any help appreciated

    Cheers

    Dean

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: If yesterday is a Sunday return Fridays date otherwise Return yesterdays date

    Choose(weekday(date,2),3,1,1,1,1,1,2)?
    Attached Files Attached Files
    Last edited by protonLeah; 07-10-2022 at 06:50 PM.
    Ben Van Johnson

  3. #3
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,206

    Re: If yesterday is a Sunday return Fridays date otherwise Return yesterdays date

    For example
    Please Login or Register  to view this content.
    or the short version
    Please Login or Register  to view this content.
    Artik
    Last edited by Artik; 07-10-2022 at 06:59 PM.

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,459

    Re: If yesterday is a Sunday return Fridays date otherwise Return yesterdays date

    Why not use workday function?

    HTML Code: 
    Quang PT

  5. #5
    Registered User
    Join Date
    02-04-2018
    Location
    Canberra, Australia
    MS-Off Ver
    2013
    Posts
    74

    Re: If yesterday is a Sunday return Fridays date otherwise Return yesterdays date

    Thankyou all for your suggestions @Artik I used your code in the end, short version, but all work just as well as each other.

    Cheers

    Dean

+ 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] How to return yesterdays date unless today is monday then return previous fridays date
    By ciaron178 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-10-2019, 10:15 AM
  2. [SOLVED] Return next Sunday's date beginning this Friday.
    By josephdemars in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-22-2015, 02:13 PM
  3. [SOLVED] Dates in Excel - If Saturday or Sunday, return Friday's date
    By gjrr4x1 in forum Excel General
    Replies: 6
    Last Post: 02-12-2015, 02:56 PM
  4. [SOLVED] Find yesterdays date in range and return row number to be used in offset
    By graphicgoose in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-13-2014, 09:20 PM
  5. [SOLVED] Add days to a date but not letting it return a Sunday
    By heresteve2 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-30-2014, 08:15 PM
  6. shows fridays date not sunday (or last working day)
    By thedeadzeds in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-28-2014, 03:44 PM
  7. [SOLVED] Formula to return a True/False if date equals yesterday's date
    By abbeycrombie in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-17-2013, 11:31 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