Need to add todays date everytime i save file

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
2,125
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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:
Upvote 0
hi thanks for the resposne, but i am getting these in red? like something is wrong

Code:
ActiveWorkbook.SaveAs Filename:=fname,_
Application.DisplayAlerts = True
 
Upvote 0
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.
 
Upvote 0
o yeah sorry I don't know why I cut that off. It was the file format
Code:
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

Thanks
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top