Macro to create worksheets

Solved/Closed
Mike Nohra - 20 Mar 2012 à 03:25
 Mike - 21 Mar 2012 à 10:13
Hello,

I'm Mike, I'm new to Macro excel

I need a Macro that read from a table the name of projects and create for each project a sheet named the same name as the project and containing a sample table created in Sheet2.
so i need to create sheets where the name is the same as the project and the content is the same as sheet2 ( as if i copied Sheet2).
then i will add some prjects so i need to create new sheets for the new projects but without deleting the old ones or modifiying the content of the project sheet ( i dont want to lose the data entered in each project sheet)

i appriciate your help.


2 responses

TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 555
20 Mar 2012 à 11:13
Hi Mike,

First select all the project names you want to create a sheet for. Then run the following macro:
Sub test()
Dim x As Integer
For Each cell In Selection
    x = Sheets.Count
    Sheets("Sheet2").Copy After:=Sheets(x)
    Sheets("Sheet2 (2)").Name = cell.Value
    Next cell
End Sub

When you enter new project names, simply select only the new ones and run the macro again.

Best regards,
Trowa
Wow Great,

Thank you.