I have a macro that will save a file to a particular directory with a date string attached to the end of the filename. It works great if there is no file with that name already in the target directory. But if the file does exist and you click that you don't want to overwrite, it sends you into the debug module.
There are two things I would like to know how to do.
1. Have the macro end if the file already exists so it won't go into the debug module.
2. After it saves the file, I would like to remain in the original spreadsheet and not have it put me in the newley named spreadsheet.
Here is my current code:
Sub test()
Dim strdate As String
strdate = Format(Now, "mm-dd-yyyy")
With ActiveWorkbook
.SaveAs "W:\Water Quality\Spreadsheets\Archived Data\Water Plant Operations Spreadsheet " & strdate & ".xlsm"
End With
End Sub
Any help would be greatly appreciated. I am not very experienced at programming.
Bookmarks