+ Reply to Thread
Results 1 to 11 of 11

Macro to re-name a file to yesterday date in a specfic directory

  1. #1
    Registered User
    Join Date
    03-25-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    26

    Macro to re-name a file to yesterday date in a specfic directory

    Hi Mate,

    Excel noob here.

    I am trying that my macro to re-name a file which is on my desktop to yesterday's date i.e 'File 4-8-13'

    Macro which i record doesn't record this action. How can i make this happen ?

    Please Login or Register  to view this content.
    I want macro to re-name this 'file.xlsx' to yesterdays date. i.e 'File 4-8-13.xlsx' - If possible - ta

    Sorry for the trouble guys, thanks in advance

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Macro to re-name a file to yesterday date in a specfic directory

    I don't think i can help you enough with the solution of your question.

    But what's underbeneath this question.

    It's just one file, so why not change it manualy?
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    03-25-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Macro to re-name a file to yesterday date in a specfic directory

    Quote Originally Posted by oeldere View Post
    I don't think i can help you enough with the solution of your question.

    But what's underbeneath this question.

    It's just one file, so why not change it manualy?
    Thanks for the reply.

    I have to run a file every day which pulls data from a SQL server, sorts it then it needs to be saved.

    For audit purposed i still require yesterdays file however changed to yesterdays date.

    If this is not possible in excel then its ok. I thought i ask.

    Ta

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Macro to re-name a file to yesterday date in a specfic directory

    Maybe you can save the file of today, with todays date (e.g. with an macro) and save the file.

    Then tomorrow, today will be yesterday.

  5. #5
    Registered User
    Join Date
    03-25-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Macro to re-name a file to yesterday date in a specfic directory

    'Maybe you can save the file of today, with todays date (e.g. with an macro) and save the file'

    Excellent reply, however above is not possible as this file is used with a number of Vlookups & other formulas ( in a lot of different other workbooks which i don't have full access to) hence can't be saved under today's date.

    So is this not possible in excel ? no code which re-names an exisiting file ?

    sorry for the bother.

  6. #6
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Macro to re-name a file to yesterday date in a specfic directory

    I think it can be done (maybe not by me).

    But again probably it is the wrong approach.

    What's differant in the todays file compared with yesterday's file.

    You don't work with an template?

  7. #7
    Registered User
    Join Date
    03-25-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Macro to re-name a file to yesterday date in a specfic directory

    Well, its for a project which changes all the time. i mean the data.

    New records get added everyday, old ones deleted. amended. etc etc

    Its easier to use the orignal file & then use the raw data to drive reports etc.

  8. #8
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Macro to re-name a file to yesterday date in a specfic directory

    Then again.

    What's wrong with save it with today's date?

  9. #9
    Registered User
    Join Date
    03-25-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Macro to re-name a file to yesterday date in a specfic directory

    todays file can't have any date as lot of other files pull information from it.

  10. #10
    Forum Contributor
    Join Date
    08-11-2012
    Location
    bengalur
    MS-Off Ver
    Excel 2003, 2007
    Posts
    152

    Re: Macro to re-name a file to yesterday date in a specfic directory

    I hope below code will help you in saving the file.

    Dim wk as WorkBook
    Set wk = WorkBook.Open("C:\Documents and Settings\Shyam\Desktop\File.xlsx")
    wk.SaveAs("C:\Backup\File " & Format(Now() - 1, "dd - mm - yyyy") & " .xlsx")
    wk.Close(True)

  11. #11
    Registered User
    Join Date
    03-25-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Macro to re-name a file to yesterday date in a specfic directory

    @ Shuamhappy - Many thanks for the response, i was away.

    Just tried your code & it debugs ! is it me ? Sorry for the trouble

    Please Login or Register  to view this content.

+ 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] Macro to browse for an excel file in a specfic directory
    By lsteinbach in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-27-2012, 12:45 PM
  2. [SOLVED] Saving a file with a specfic date from a cell.
    By NissanX in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-31-2012, 11:02 AM
  3. Macro to insert yesterday s date
    By Marc Gauthier in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-21-2007, 07:28 AM
  4. Open File with name incorporating ~yesterday's date
    By achidsey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-21-2005, 10:05 PM
  5. Open file based on yesterday's date
    By ForSale in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2005, 02:05 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