Save File with Time Stamp

nniedzielski

Well-known Member
Joined
Jan 8, 2016
Messages
598
Office Version
  1. 2019
Platform
  1. Windows
I am running a macro that finishes by saving the file to a new path, while Killing the Old File. Which is awesome. How though can I get the file to save as with the file name being "ITA with the date and time it was saved?

So it would save right now as ITA4_29_2016 1527

Yes I would like it to be 24 hour clock if possible as well.

Right now it is just saving as ITA because that was the old name.

heres my code as of right now:

Code:
y.Activate        Dim NewPath As String, OldFile As String
    
            NewPath = "C:\IB Macro\ITA USED\"
    
            OldFile = ActiveWorkbook.FullName
            ActiveWorkbook.SaveAs NewPath & ActiveWorkbook.Name
            Kill OldFile


thank you,
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
What extension is being used to save the file (.xls, .xlsx, etc)?
 
Upvote 0
Try:
Code:
            Dim NewPath As String, OldFile As String, NewFile As String
    
            NewPath = "C:\IB Macro\ITA USED\"
    
            OldFile = ActiveWorkbook.FullName
            NewFile = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & _
                Format(Now(), "m_d_yyyy hhmm") & ".xls"
            ActiveWorkbook.SaveAs NewPath & NewFile
            Kill OldFile
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,457
Members
449,083
Latest member
Ava19

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