PDA

View Full Version : VBA script to move files from one folder to 3 and populate list of files



jackreacher3
07-01-2013, 08:56 PM
Hello I need help with a VBA Macro to work through column a (cost centre) in 2 tabs move these files to a new directory, look at the remaining files move these to a new destination folder and list these in an excel spread sheet.

Firstly, it will look at the 1.Distribution list (tab 1) and carry out an 'exact
match' against cost centre (please note this number can be varying in size and can be either numeric, or alphanumeric or a combination, this list will change from month to month) and move the excel files with these numbers from the its source folder to its destination folder:

Source folder "C:\Users\TEST\Desktop\Report Seperator\1.All Reports"
Destination folder called C:\Users\TEST\Desktop\Report Seperator\2.Distribution List

Secondly, it will look at 2.Excusions (tab 2) and carry out an 'exact match' against cost centres (please note this number can be varying in size and can be either numeric, or alphanumeric or a combination, this list will change from month to month) and move the excel files with these numbers from the its source folder to its destination folder:

Source folder "C:\Users\TEST\Desktop\Report Seperator\1.All Reports"
Destination folder called C:\Users\TEST\Desktop\Report Seperator\3.Exclusions

Finally, all the reports left within the source folder will need be moved to a new destination

Source folder "C:\Users\TEST\Desktop\Report Seperator\1.All Reports"
Destination folder C:\Users\TEST\Desktop\Report Seperator\3.New Centres.


I would then like the script to look at Destination folder C:\Users\TEST\Desktop
\Report Seperator\3.New Centres and capture these names within the tab 3.New Centres.

I have drafted the input and output files in excel, if you require these please drop me a line.

Many thanks foryour help.

P.S I have created the template if anyone needs to look at this.

SamT
07-02-2013, 02:35 PM
Oh, yeah. We'll need your examples.

If you use the "Go Advanced" button that editor will have a "Manage Attachments" button to upload files.

jackreacher3
07-03-2013, 12:15 AM
Hello,

Please find attached the Report separator file and blank report names. I have populated these in the folder 1. all reports.

Please note, the centres vary in length and type from month to month, so cannot be hard coded. They should also be an "exact match" in column a of each tab.

Secondly report files have been named for this example only, with E for exclusions and N for New, all other files names are exactly as is on the distribution tab.

Many thanks