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
What's the 007 or the 008? Is that a counter? What does that have to do with the date?
You can use something like this:
File_Name = Range("E4").Value & Format$(Range("H4").Value, "000") & ".xlsb"
@Velouria
Perfect!!!! Thanks so much! I kept getting "FALSE" for my filename with all my attempts! Thanks so much!