View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Forgone Forgone is offline
external usenet poster
 
Posts: 60
Default VBA to move WS from 1workbook to another based on critieria

I've created a series of workbooks by using a macro to filter out data
and export it to a workbook for two separate tasks. I now have 2
folders each with a series of workbooks (Folder 1 & Folder 2). Folder
1 is the non-salary budget file and Folder 2 is the salary budget
file.

The file names are in the format of 234-2340100-101-99999999.xls in
Folder 1 and in Folder 2 its 234-2340100-101-99999999 - salary.xls

What I'm hoping to do, primarily to save time, is to automate it
rather than doing it manually (52 workbooks). What I would like to do
is to run a macro that will

A) Look at a workbook in Folder 1, if its finds a match in Folder 2
(trim " - salary.xls") it will copy the worksheet from the workbook in
Folder 2 into the workbook in Folder, save the file in a new directory
(OUTPUT) and add the text " - done" to the file in Folder 2. (That way
I can identify if there is a file in Folder 2 which doesn't have a
corresponding file in Folder 1)
B) If there isn't a matching workbook in Folder 2, it will save the
workbook from Folder 1 into the output directory.
C) If there is a workbook in Folder 2 and there is no matching
workbook in Folder 1 then it would save the workbook in the Output
folder.

I believe this would be possible, but I'm not sure how to do it.