PDA

View Full Version : Need help seperating files



cmendez
10-03-2014, 03:08 PM
Hi,


I am currently running a macro that runs through a workbook and outputs other workbooks and saves them indipendently.

What I am having trouble doing is that I have a list of people that only get certain reports and I need to find a way to seperate the outputs into their own folders.

For example,

Person 1 and Person 2 each get 15 reports a piece, each report is different, once my macro outputs those 30 reports I need it to sort them into their own folders for Person 1 and Person 2.

I am really new at this so my only solution to this is have a MkDir for each person then FileCopy and refer back to each file, which works but is time consuming doing this for 86 people.

ranman256
10-06-2014, 05:37 AM
Your request makes no sense. What do you mean, 'runs thru a workbook and outputs workbook" ?
So you mean Save the workbook to another workbook in a particular folder?

cmendez
10-06-2014, 09:22 AM
I guess to make it more simple is I need a macro that will find files from a predetermined list (they are all going to be grouped in 1 folder initially)and move them to their appropriate folder, e.g. bob.xlsx, tom.xlsx go to Folder 1, sara.xlsx, jesse.xlsx go to folder 2.

ranman256
10-07-2014, 06:14 AM
This macro looks at a cell to see the SOURCE folder where all files start. G5
Then scans the list Col A is xl name, col B is the target folder



Public Sub MoveFiles()
Dim vSrcDir, vTargDir, vNewFile, vSrcFile
On Error Resume Next
vSrcDir = FixDir(Range("G5").Value)

'scan all files in list
Range("A1").select
While ActiveCell.Value <> ""

vSrcFile = vSrcDir & ActiveCell.Value
vTargDir = FixDir(ActiveCell.Offset(0, 1).Value)

vNewFile = vTargDir & ActiveCell.Value
'archive
Name vSrcFile As vNewFile
'Debug.Print vSrcFile, vNewFile
Next
End Sub

cmendez
10-07-2014, 09:12 AM
Thank you for the assistance ranman !

One last question, how do I assign the sheet that the macro will be referring too?

I am also getting Compile error: Sub or Function not defined, is there a reference that has to be enabled?

I apologize if this is a dumb question I am really new to this.