szakharov7723
Board Regular
- Joined
- Jun 22, 2018
- Messages
- 85
- Office Version
- 2019
- Platform
- Windows
So my code works differently in a the same file, but in a different file path
Sub SaveAsExample()
The way it should work:
First it saves the file based on date in cell and filepath in cell
IF the file already exists ,it naturally asks if I want to replace this file , if I say yes --it replaces. If I say no --it creates file name and adds _2.
BUT when all I do is paste this file to another folder ,it no longer asks me if I want to replace the file ,and adds _2 right away, if file name already exists.
Any ideas how is it possible ?
Sub SaveAsExample()
Code:
Dim FName As String
Dim FPath As String
On Error GoTo Handler:
FPath = Sheets("Setup").Range("A1").Text
FName = Sheets("Setup").Range("G1").Text
ThisWorkbook.SaveAs Filename:=FPath & "\" & FName
Exit Sub
Handler:
FPath = Sheets("Setup").Range("A1").Text
FName = Sheets("Setup").Range("G1").Text
ThisWorkbook.SaveAs Filename:=FPath & "\" & FName & "_2"
End Sub
The way it should work:
First it saves the file based on date in cell and filepath in cell
IF the file already exists ,it naturally asks if I want to replace this file , if I say yes --it replaces. If I say no --it creates file name and adds _2.
BUT when all I do is paste this file to another folder ,it no longer asks me if I want to replace the file ,and adds _2 right away, if file name already exists.
Any ideas how is it possible ?