+ Reply to Thread
Results 1 to 5 of 5

Previous working days date (Mon-Fri working week).

  1. #1
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    Previous working days date (Mon-Fri working week).

    Im trying to open a file which is named the previous working days date.

    For example on Monday the date was 18-07-11. So the file i wanted to open was Fridays file which was named 15-07-11.xls as per fridays date.

    Im trying to write a macro that reads todays date, calculates the previous working days date / stores the date in a variable, use whats stored in the variable (to create the filename) to open the previous working days file.
    Last edited by intothewild; 07-22-2011 at 01:10 PM.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Previous working days date (Mon-Fri working week).

    Try the following code. It assumes your file is in the same directory as the calling file.
    Note that the function used remove leading zero so today's file name would be 20-7-2011.xls
    It would be a good thing to have a similar macro and function to save each working day file.

    Please Login or Register  to view this content.
    Last edited by p24leclerc; 07-20-2011 at 10:19 PM.

  3. #3
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: Previous working days date (Mon-Fri working week).

    Quote Originally Posted by p24leclerc View Post
    Try the following code. It assumes your file is in the same directory as the calling file.
    Note that the function used remove leading zero so today's file name would be 20-7-2011.xls
    It would be a good thing to have a similar macro and function to save each working day file.

    Please Login or Register  to view this content.
    When i tried this it gave out todays date.
    What happens with 'open_date' in the code above?

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Previous working days date (Mon-Fri working week).

    Sorry about that, I forgot to subtract 1 day to actual date to open previous day report when it is not on Monday.
    make the following modification and it should go right.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: Previous working days date (Mon-Fri working week).

    Needed to switch Act_date in yours for open_date aswell it was the wrong way round when putting together file_name2.

    Thanks for your help, its a nice neat way of doing it.... 'tis like this...

    Please Login or Register  to view this content.
    Last edited by intothewild; 07-22-2011 at 01:05 PM.

+ 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