Results 1 to 5 of 5

Thread: Need to add todays date everytime i save file
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Mar 2016
    Posts
    1,860
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Need to add todays date everytime i save file

    Code:
    ChDir "C:\Users\frank\Desktop\OCIP"
    ActiveWorkbook.SaveAs Filename:="C:\Users\frank\Desktop\OCIP\LCP.xlsx", _

    The file I am saving is called LCP. I would like it to be saved different every time with today's date on it every time I save it. Something like this

    LCP - 08-23-2019

    Also if it picks up that I am saving it again it can override it without asking me to replace it.

    Any help thank you

  2. #2
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    50,772
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Need to add todays date everytime i save file

    Try:
    Code:
    Dim fname as String
    fname="C:\Users\frank\Desktop\OCIP\LCP - " & Format(Date,"mm-dd-yyyy") & ".xlsx"
    ChDir "C:\Users\frank\Desktop\OCIP"
    Application.DisplayAlerts=False
    ActiveWorkbook.SaveAs Filename:=fname, _
        ...
    Application.DisplayAlerts=True
    Last edited by Joe4; Aug 23rd, 2019 at 01:36 PM.
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  3. #3
    Board Regular
    Join Date
    Mar 2016
    Posts
    1,860
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need to add todays date everytime i save file

    hi thanks for the resposne, but i am getting these in red? like something is wrong

    Code:
    ActiveWorkbook.SaveAs Filename:=fname,_
    Application.DisplayAlerts = True

  4. #4
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    50,772
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Need to add todays date everytime i save file

    In your original posting, you cut off your code aftet that comma. That indicates that line of code is continued. But since you cut it off, I do not know what it was, which is what I had placed the "..." in there. Just place whatever was in your original code next in that spot. And after that line, place the last line of code I posted.
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  5. #5
    Board Regular
    Join Date
    Mar 2016
    Posts
    1,860
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need to add todays date everytime i save file

    o yeah sorry I don't know why I cut that off. It was the file format
    Code:
    FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
    Thanks

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •