December 4, 2021
Okay, the code below works perfectly, however my issue is that in addition to the backup filename being saved, a copy of the template workbook is also saved. My "template" is an xlsb file that includes a version #, as I am constantly making upgrades. After this macro has been tweaked, the version # will again change. The file name on "Main" cell B21 and "codes " O2 is the same file name, while is used and my original and then a copy for the back up. The second screenshot shows my "updates" folder (path on "codes" as shown in 1st screenshot), with the template folder. I have deleted 11 copies of this template between yesterday and today from my Updates folder. What is wrong with my code? I cannot figure it out.
' Save file as multiple cell references
' Macro Complete - Checkmark added (to Main Sheet)
Sheet7.Range("$K$8").Value = ChrW(&H2713)
Call Insert_End
'' Call Formula_Value
Dim fname As String
Dim FPath As String
Dim backupfolder As String
' Save Active Workbook
ThisWorkbook.Save
' Save Audit file
' Save COPY of Active Workbook (with new filename)
'Path of file
FPath = Sheets("Main").Range("B7").Value
' New file name WITHOUT extension
fname = Sheets("Main").Range("B21").Text & ".xlsb"
ThisWorkbook.SaveCopyAs Filename:=FPath & "\" & fname
' Save Backup file
' Save COPY of Active Workbook (with new filename)
' Path of file
backupfolder = Sheets("codes").Range("O2").Value
' New file name WITHOUT extension
fname = Sheets("Main").Range("B21").Text & ".xlsb"
ThisWorkbook.SaveCopyAs Filename:=backupfolder & "\" & fname
' Save Confirmation
If Err.Number <> 0 Then
MsgBox Err.Description
Else
MsgBox "Original File saved AND a Copy of the File Saved as " & backupfolder & "\" & fname
End If
Call Save_BackUp
'' ' Save Workbook & Close File (NEW Workbook) ' Deactivated until Template has been fixed!
'' ActiveWorkbook.Close SaveChanges:=True
ActiveWorkbook.Save
End Sub
1 Guest(s)