Hi all,
I have the below macro for saving a copy of workbook (original wkbk called macro):
Sheet1.Select
Cells.Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
ActiveWorkbook.SaveAs Filename:= _
"\\Daily\Name " & Date & ".xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
However, if there is already an existing workbook with the same name in path, excel will prompt msg asking if I want to replace with options Yes, No and Cancel. If I choose, No or Cancel, a End or Debug error msg is shown.
How can I configure a macro such that if I select =
No, on prompt - there will not be any end or debug error msg, and excel will do nothing. I can decide what I can to do with the newly create workbook later.
Cancel, on prompt - no end or debug error msg, and excel will not save the newly create workbook (automatically named as book2) but auto delete it, and will direct me back to original workbook.
Thanks!
I have the below macro for saving a copy of workbook (original wkbk called macro):
Sheet1.Select
Cells.Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
ActiveWorkbook.SaveAs Filename:= _
"\\Daily\Name " & Date & ".xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
However, if there is already an existing workbook with the same name in path, excel will prompt msg asking if I want to replace with options Yes, No and Cancel. If I choose, No or Cancel, a End or Debug error msg is shown.
How can I configure a macro such that if I select =
No, on prompt - there will not be any end or debug error msg, and excel will do nothing. I can decide what I can to do with the newly create workbook later.
Cancel, on prompt - no end or debug error msg, and excel will not save the newly create workbook (automatically named as book2) but auto delete it, and will direct me back to original workbook.
Thanks!