Hello everyone! I am working on a workbook that contains multiple sheets. I use a macro to back up my sheets everytime I save them (with a special command). Additionally, I create .txt files each time for the game I'm developing. However this macro doesn't seem to perform too well (time-wise), I feel it can be improved, but I'm not sure how. Here is the code:
Sub Save()
'
' Save Macro
'
' Keyboard Shortcut: Ctrl+Shift+S
'
Dim Path As String
Dim MyDate
MyDate = Date
Dim MyTime
MyTime = Time
Dim StrTime As String
StrTime = Format(MyTime, "hh.mm.ss")
Dim StrDate As String
StrDate = Format(MyDate, "YYYY-MM-DD")
ExcelPath = "C:\Apps\...\excel\"
BackupPath = "C:\Backup\Excel\"
Application.DisplayAlerts = False
ActiveWorkbook.Save
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:=BackupPath & ActiveSheet.Name & " " & StrDate & " " & StrTime & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.SaveAs Filename:=ExcelPath & ActiveSheet.Name & ".txt", _
FileFormat:=xlText
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub
That's it. Any advice on how to reformulate and/or improve the code to speed up performance would be greatly appreciated. Thanks in advance!
Bookmarks