Save File To Folder

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,066
Help would be appreciated.

I would like a script which would save my file named Xtemplate to a folder named C:\Temp\ExcelTemplates\

The only thing is I would like it if the script could add a new number to the file name if the file already exists in the destination folder.

I.e. Xtemplate already exists so save file as
Xtemplate1 (if Xtemplate1 exists, save as)
Xtemplate2 (if etc... etc....)
 
Thanks for your help Xenou and John.

I have used John's example and it works perfectly, greatly appreciated.:):):)
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
ansariemacaurog, I need more details, like what is the file being saved, do you want to save the file in the new folder, is the folder name in A2 the full folder path including the new folder name or just the new folder name?

But at its simplest, suppose A2 on Sheet1 contains C:\temp\Excel\newFolder, the following code will create newFolder, but only if all preceding folders exist (C:\temp and C:\temp\Excel):
Code:
Sub CNF()
    If Dir(Sheets("Sheet1").Range("A2").Value, vbDirectory) = "" Then
        MkDir Sheets("Sheet1").Range("A2").Value
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,126
Members
452,381
Latest member
Nova88

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