Automate filename in Excel

  • Thread starter Thread starter Kua
  • Start date Start date

Kua

Kua

Associate
Joined
21 Jul 2008
Posts
512
Location
Lancaster
Hi,

I haven't done any coding in a long while and VBA is new to me. I want the file to save in the format, <YYYY><MM><DD>MITC_it_house.etl

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim strDate As String
strDate = Format(Now, "yyyyMMdd")

ActiveWorkbook.SaveAs ("<File Path>" & strDate & "MITC_it_house.xlsm")

End Sub

I got the code snippet from here.

Thanks.
 
Last edited:
Back
Top Bottom