Alrighty,
I'm not sure this was the easiest way to do it, but I believe it will get the job done. I have designed a macro for you that first copied the unique CostCtr values from column C in the template workbook to column N. Then it loops through those values opening up the workbook whose name begins with that number in the filepath you specify. It then loops through the cells in column C again and if they match the current value in the CostCtr loop/CostCtr workbook open then it copies and pasted that cells row from column B to L into the CostCtr's workbook. It then closes and saves the workbook and moves to the next until it is finished.
To insert this code into your workbook:
1. Press Alt+F8
2. clear the macro name field and then type ExportCostCtr
3. Select the Create option
4. In between the Sub ExportCostCtr() and End Sub, copy and paste the below code
5. anything that appears in green is a comment left, hopefully to help you understand. Please read through the code to find the line of code
6. Above this line of code are directions to help you change the filepath name. You'll need to change this in order for you code to work properly.
7. Exit out of visual Basic
8. Right click on the Export shape in column A that you created and select assign macro
9. Select the ExportCostCtr macro and select okay.
10.Finally click on the Export Data button and hopefully watch it work.
Let me know if you have any questions.
Thanks!
Bookmarks