ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sub to copy n rename book according to list (https://www.excelbanter.com/excel-programming/409960-sub-copy-n-rename-book-according-list.html)

Max

Sub to copy n rename book according to list
 
Hi, seeking help for a sub to do this
In D:\Max, I've got 2 "template" books prepared
DBrT.xls
PBrT.xls

In Sheet1, I've got the List of D Branch names in col A, List of P Branch
names in col B, eg:
In A1 down
Dxx1
Dxx2
Dxx3
....
In B1 down
Pzz1
Pzz2
Pzz3
....

I would like to run a sub from Sheet1 which will create a folder (ie
D:\Max\DBrT) & then copy/rename DBrT.xls according to the list of D Branch
names in col A into this folder. And to do likewise for the P Branch names
(copy/rename PBrT.xls into D:\Max\PBrT), so that I'd end up with this:

In D:\Max\DBrT
Dxx1.xls
Dxx2.xls
Dxx3.xls
....

In D:\Max\PBrT
Pzz1.xls
Pzz2.xls
Pzz3.xls
....

Thanks



Max

Sub to copy n rename book according to list
 
Found some code from Ron's page:
http://www.rondebruin.nl/folder.htm

Tinkered with Ron's: Sub Copy_One_File() like below
(I had to pre-create the dest. folder: D:\Max\DBrT, but this is not a
problem)

Sub Copy_One_File()
FileCopy "D:\Max\DBrT.xls", "D:\Max\DBrT\Dxx1.xls"
FileCopy "D:\Max\DBrT.xls", "D:\Max\DBrT\Dxx2.xls"
FileCopy "D:\Max\DBrT.xls", "D:\Max\DBrT\Dxx3.xls"
End Sub

The above works ok in my tests, but I don't know
how to get it to loop through & read/use all the destination names, ie:
Dxx1
Dxx2
Dxx3
etc
from the list of 100+ branch names that's placed in col A in the active
sheet?
Thanks for insights / any alternatives




All times are GMT +1. The time now is 01:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com