VBA to create new workbook with corresponding worksheets

kh79466

New Member
Joined
Sep 27, 2011
Messages
1
Hi Everyone,

I am new to VBA code and was tasked with finding a way to create a macro that would look at a list in a worksheet and create a new workbook for each unique name in the list (column b) but also copy an entire sheet as a new worksheet for each dept (column a) that corresponds to the person's name in column b.

For example I have two tabs or sheets in an excel workbook named 1) Template 2) List

The list tab gives information as follows:

Column A (Dept)
2
3
4
5
6
7
8
9
10

Column B (Name)
Joe
Jane
Josh
Josh
Josh
John
John
Mike
Bill
Cindy

The template tab has information that will be populated via the department number in D2.

So I need the macro to do two things:

1) I need it to run through this list and create a workbook for each Unique Name
2) I need it to then copy the template worksheet (everything in the worksheet) into the newly created workbook for as many departments as the unique name has, with the new worksheet being named after the departments and the department number populating into the D2 cell in the copied template.

Example:

Create workbook called Josh, within that workbook there are three sheets labeled 3, 4, 5 for his corresponding departments and each of the sheets has all the information from the original copied template and 3,4,5 appear in each sheets D2 cell. Save workbook to My documents


Let me know if you need more information or clarification. Any help would be much appreciated. I have started trying to form code but nothing is producing what I need it to and have been coming up empty handed.

I am using excel 2007.
 
Last edited:

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,224,518
Messages
6,179,259
Members
452,901
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top