File Names

Silo

Active Member
Joined
Mar 8, 2004
Messages
447
Hello everyone

It’s been a while since I needed some help from the experts here.

I have a task I would like some assistance with…

I have a work book that I have to copy over 70 times for over 70 work locations. As you can see, this will require different file names for each location.

I would like some have help with a code that I can use. If possialbe I like a code that will make copies of the file renaming each with the names I have on another list. Is this feasible?

Any help would be appreciate it

Thank you guys in advance
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

jmthompson

Well-known Member
Joined
Mar 31, 2008
Messages
966
If you were going to create a list of filenames to maintain, you might as well keep it in the macro. Here is code you can modify for your use.

Update myPath to equal the path you want to assign to the resulting files (assuming you want them all saved in the same or similar place)

Update MyF to any portion of the resulting file name that will be common to all resulting files.

If you need help figuring out myPath and MyF, let me know


Code:
Sub Save_As()
Application.DisplayAlerts = False
myPath = "C:\Big Folder\Little Folder\tiny folder\"
myF = "newfile"
ActiveWorkbook.SaveCopyAs myPath & myF & "1.xls"
ActiveWorkbook.SaveCopyAs myPath & myF & "2.xls"
ActiveWorkbook.SaveCopyAs myPath & myF & "3.xls"
ActiveWorkbook.SaveCopyAs myPath & myF & "4.xls"
ActiveWorkbook.SaveCopyAs myPath & myF & "5.xls"
ActiveWorkbook.SaveCopyAs myPath & myF & "6.xls"
ActiveWorkbook.SaveCopyAs myPath & myF & "7.xls"
Application.DisplayAlerts = True
End Sub
 
Upvote 0

jmthompson

Well-known Member
Joined
Mar 31, 2008
Messages
966
It might be helpful if I tell you the above code would result in the following files:
C:\Big Folder\Little Folder\tiny folder\newfile1.xls
C:\Big Folder\Little Folder\tiny folder\newfile2.xls
C:\Big Folder\Little Folder\tiny folder\newfile3.xls
C:\Big Folder\Little Folder\tiny folder\newfile4.xls
C:\Big Folder\Little Folder\tiny folder\newfile5.xls
C:\Big Folder\Little Folder\tiny folder\newfile6.xls
C:\Big Folder\Little Folder\tiny folder\newfile7.xls
 
Upvote 0

Silo

Active Member
Joined
Mar 8, 2004
Messages
447
Hello jmthompson

I edited the code and get an error, the error says

Complie error, Syntax error

Then the debuger points to...

ActiveWorkbook.SaveCopyAs myPath & T1 Butler July - Dec 2008 & ".xls"

Can you tell me what I've overlooked?

Thanks
 
Upvote 0

Forum statistics

Threads
1,191,076
Messages
5,984,497
Members
439,893
Latest member
johnsboxftm

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
Top