Is this poosible - a macro to 'Save As' with incremental date

Mel Smith

Well-known Member
Joined
Dec 13, 2005
Messages
1,041
Office Version
  1. 365
Platform
  1. Windows
I am trying to automate the extraction/copying of data from a master workbook into a 'daily' workbook. The copying and pasting etc. I can do but what I would also like to include in my code is to do a Save As of my 'new' daily workbook with each days date. So today it will be called MRE_040118, tomorrow MRE_050118 and so on. Is this possible?

Mel
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Mel,

I accomplished this in a project as follows:

' Establish 2 variables
Dim ReportDate as String
Dim Fname as String

' Store Today's Date to ReportDate
ReportDate = Today()
ReportDate = Format(ReportDate, "dd-mm-yy"
Fname = ActiveWorkbook.name & "_" & ReportDate

' Then when saving the file set filename = Fname
fineName:=Fname
 
Upvote 0
Many thanks, Frank!

Mel
 
Last edited:
Upvote 0
I typed in frank-AL's solution but the macro 'hung' at the line ReportDate = Today()

Have I done something wrong or is there another way to do this?

Mel
 
Upvote 0
How about
Code:
Sub Chk()
   Dim Fname As String
   Fname = ActiveWorkbook.Name & Format(Date, "ddmmyy")
   ActiveWorkbook.SaveAs Fname, 52
   
End Sub
This will save as an .xlsm workbook
 
Upvote 0
Thanks, Fluff. Can you tell me what the Fname, 52 means, please?
 
Upvote 0
Fname is the file name (created on the line of code above the save as)
52 is the file format, which is an xlsm file
 
Upvote 0
Sorry to be a pain... Your code works fine, thanks. However, it saves the new file to my OneDrive documents and I really want it to be saved to my C: drive/My Documents. How may I achieve this?
Mel
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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