I have struggled to generate a form that can be updated with a button click.
The program generates a DateTime stamp then copies the sheet to a file
My issue is that I want to delete the sheet once saved to file and return to the original but I keep getting errors (no matter which method I try).
Any advice or information pertaining to a solution is greatly appreciated.
Cheers in advance,
Cmack.
Private Sub CommandButton2_Click()
Application.CalculateFull 'sets the clock
Application.ScreenUpdating = True 'updates the screen
Dim FName As String 'declares file name
ActiveSheet.Copy 'copies original
With ActiveSheet.Range("A1") ' correct date and time
.Copy
.PasteSpecial xlValues
.PasteSpecial xlFormats
Application.CutCopyMode = False
Application.ScreenUpdating = False
End With
Application.DisplayAlerts = False 'no alerts
FName = "C:\Users\cmack\OneDrive\Desktop\Testing\" & Format(Range("A1"), "hh-MM--ss-mmm-d-yyyy") & ".xlsm"
ActiveWorkbook.SaveAs Filename:=FName, FileFormat:=xlOpenXMLWorkbookMacroEnabled 'saves the new copy (date stamped title) into folder
??????????? How to delete the newly copied sheet?????????
End Sub
The program generates a DateTime stamp then copies the sheet to a file
My issue is that I want to delete the sheet once saved to file and return to the original but I keep getting errors (no matter which method I try).
Any advice or information pertaining to a solution is greatly appreciated.
Cheers in advance,
Cmack.
Private Sub CommandButton2_Click()
Application.CalculateFull 'sets the clock
Application.ScreenUpdating = True 'updates the screen
Dim FName As String 'declares file name
ActiveSheet.Copy 'copies original
With ActiveSheet.Range("A1") ' correct date and time
.Copy
.PasteSpecial xlValues
.PasteSpecial xlFormats
Application.CutCopyMode = False
Application.ScreenUpdating = False
End With
Application.DisplayAlerts = False 'no alerts
FName = "C:\Users\cmack\OneDrive\Desktop\Testing\" & Format(Range("A1"), "hh-MM--ss-mmm-d-yyyy") & ".xlsm"
ActiveWorkbook.SaveAs Filename:=FName, FileFormat:=xlOpenXMLWorkbookMacroEnabled 'saves the new copy (date stamped title) into folder
??????????? How to delete the newly copied sheet?????????
End Sub