Excel - A macro to create worksheets

March 2017



Issue


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.

Solution


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.

Thanks to TrowaD for this tip.

Related


Published by aakai1056. Latest update on July 30, 2012 at 08:32 AM by aakai1056.
This document, titled "Excel - A macro to create worksheets," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).