Hello all,
Short question from me if you have a few seconds:
- I have the following VBA that saves the active sheet in a folder on the desktop
- the problem that I am facing is that if I try to save the file again (it might happened that the file saved by other colleagues have the same name), it tells me that the file already exists. I am trying to change this code and make it add a "-1", "-2"... at the end, if file exist.
So if the initial name of the file is test.xlsx and I try to save the file again with the same name, the new file should be named test-1.xlsx, if I save it again the name should be named test-2.xlsx and so on.
Thank you
Short question from me if you have a few seconds:
- I have the following VBA that saves the active sheet in a folder on the desktop
VBA Code:
With Application.FileDialog(msoFileDialogSaveAs)
.InitialFileName = Path & "\" & Format(Range("K2"), "YYMMDD") & "_" & Range("L12") & "_(" & NM & " )" & "_" & Range("P3") & ".xlsx"
.Show
.Execute
End With
- the problem that I am facing is that if I try to save the file again (it might happened that the file saved by other colleagues have the same name), it tells me that the file already exists. I am trying to change this code and make it add a "-1", "-2"... at the end, if file exist.
So if the initial name of the file is test.xlsx and I try to save the file again with the same name, the new file should be named test-1.xlsx, if I save it again the name should be named test-2.xlsx and so on.
Thank you