Sub to copy n rename book according to list

M

Max

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
 
M

Max

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top