Need to add todays date everytime i save file

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
1,908
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
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,412
Office Version
365
Platform
Windows
Try:
Code:
Dim fname as String
fname=[COLOR=#333333]"C:\Users\frank\Desktop\OCIP\LCP - " & Format(Date,"mm-dd-yyyy") & ".xlsx"
[/COLOR]ChDir "C:\Users\frank\Desktop\OCIP"
Application.DisplayAlerts=False
ActiveWorkbook.SaveAs Filename:=fname, _
    ...
Application.DisplayAlerts=True
 
Last edited:

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
1,908
hi thanks for the resposne, but i am getting these in red? like something is wrong

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

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,412
Office Version
365
Platform
Windows
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.
 

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
1,908
o yeah sorry I don't know why I cut that off. It was the file format
Code:
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Thanks
 

Watch MrExcel Video

Forum statistics

Threads
1,099,143
Messages
5,466,933
Members
406,511
Latest member
markflayd

This Week's Hot Topics

Top