

December 4, 2021

I thought converting an existing macro from Date to version (with leading zeros) would be somewhat easy. I was very wrong! Below is my macro which works great. It does a save as to today's date based on the cell reference that indicates the file name. Now I have added in the 2nd variable which is the version (cell H4). I need this to be display in the format of "000". So the File name would change like this shown below. I DID leave in the date portion of the previous macro, as I didn't want to mess everything up.
Sherry's Development File - 007.xlsb
Sherry's Development File - 008.xlsb
Option Explicit
Sub File_Name_As_Cell_Date()
Dim File_Name As String
Dim Destination As String
Application.DisplayAlerts = False
Destination = ThisWorkbook.Path & "\" & File_Name
' 2nd variable uses custom number format for versioning development files
File_Name = Range("E4").Value & Range("H4").NumberFormat = "mm-dd-yyyy" & ".xlsb"
' xlExcel12 is for xlsb
ActiveWorkbook.SaveAs Destination & File_Name, xlExcel12
Application.DisplayAlerts = True
''ActiveWorkbook.Close
End Sub


Trusted Members

October 17, 2018

1 Guest(s)
