How to save workbook and avoid debug error

mfreak009

New Member
Joined
Sep 21, 2006
Messages
8
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!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,214,819
Messages
6,121,737
Members
449,050
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top