Copy a sheet rename it from a list and add values in some cells

I need a macro in excel that copys a sheet called "template" for each value in a list.

each new sheet should then be named by the value in the list AND a cell within the sheet should have the name copied to it.

It sounds likea  simple task, any help please?

cookiejestAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris BottomleySoftware Quality Lead EngineerCommented:
SOmething like the following which is code in the specific workbook:

Chris
Sub nuSheets()
Dim sh As Worksheet

For Each nam In Array("fred", "doris")
    Sheets("Template").Copy After:=Sheets(Sheets.Count)
    With Sheets(Sheets.Count)
        .Name = nam
        .Range("a1").Value = Name
    End With
Next

End Sub

Open in new window

cookiejestAuthor Commented:
Ok that is almost what I need, can you explain where I would input the array A2:A45 within my sheet called "Tracking Sheet".

I assume a1 is the cell where the sheet name is pasted within it.
Chris BottomleySoftware Quality Lead EngineerCommented:
The sheet copy takes all the data from template ... Is your array a vba array that needs to be placed in the copy and if so how is it defined?

Yes a1 is the cell with the sheet name ... Albeit a typo fixed below.

Let me know re tha array and I will modify accordingly

Chris
Sub nuSheets()
Dim sh As Worksheet

For Each nam In Array("fred", "doris")
    Sheets("Template").Copy After:=Sheets(Sheets.Count)
    With Sheets(Sheets.Count)
        .Name = nam
        .Range("a1").Value = Nam
    End With
Next

End Sub

Open in new window

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Chris BottomleySoftware Quality Lead EngineerCommented:
Re-reading it looks as though the 'array' to be copied is the range a2:a45 of sheet tracking data therefore:

Chris
Sub nuSheets()
Dim sh As Worksheet

For Each Nam In Array("fred", "doris")
    Sheets("Template").Copy After:=Sheets(Sheets.Count)
    With Sheets(Sheets.Count)
        .Name = Nam
        .Range("a1").Value = Nam
        Sheets("Tracking Sheet").Range("a2:a45").Copy .Range("a2:a45")
    End With
Next

End Sub

Open in new window

cookiejestAuthor Commented:
No each item in the array (which is in cells a2:a45) needs a sheet that is based on the "template". The name of the sheet is the name of the item in the array. The same value also needs to be placed within a cell in its newly created sheet
Chris BottomleySoftware Quality Lead EngineerCommented:
In that case:

Chris
Sub nuSheets()
Dim sh As Worksheet

For Each Nam In Sheets("Tracking Sheet").Range("a2:a45").Cells
    Sheets("Template").Copy After:=Sheets(Sheets.Count)
    With Sheets(Sheets.Count)
        .Name = Nam.Text
        .Range("a1").Value = Nam.Text
    End With
Next

End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.