Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Make multiple copies of a worksheet in an Excel file

Posted on 2014-03-26
4
Medium Priority
?
337 Views
Last Modified: 2014-03-27
I have an Excel file with one worksheet named "Sheet1". Sheet1 contains a "shell".  I need the file to contain 20 copies of Sheet1 and the tabs to be named by the numbers 1 through 20.  In other words, rename Sheet1 to "1" and make 19 additional copies of it numbered 2 through 20. The expected result is an Excel file with 20 tabs numbered 1 through 20; each containing a copy of the "shell" from Sheet1.
0
Comment
Question by:dbfromnewjersey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 39956771
Hi,

pls try

Sub macro()
Dim sh As Sheets
For Idx = 2 To 21
    Sheets(1).Copy after:=Sheets(Idx - 1)
    Sheets(Idx).Name = Idx - 1
Next
Sheets(1).Delete

End Sub

Open in new window

Regards
0
 
LVL 39

Accepted Solution

by:
nutsch earned 1400 total points
ID: 39956779
This code should do exactly that:
Sub Macro1()
'
Dim lLoop As Long

For lLoop = 2 To 20
    Sheets("Sheet1").Copy After:=Sheets(Sheets.Count)
    ActiveSheet.Name = lLoop
Next lLoop

Sheets("Sheet1").Name = "1"

End Sub

Open in new window

0
 
LVL 6

Expert Comment

by:vmagan
ID: 39956781
You can also right click on the sheet name and click on move and copy. You will be able to copy it there.
0
 
LVL 13

Assisted Solution

by:Santosh Gupta
Santosh Gupta earned 600 total points
ID: 39956798
Try this...

if you want to put some specific name you can user below Macro.

"LIST" - name of sheets
"Template" -your actual sheet.
Sub CreateSheets()
    Dim i As Long
    Dim ws As Worksheet
    Dim ws1 As Worksheet
    
        Set ws = Sheets("LIST")
        Set ws1 = Sheets("Template")
        
        For i = 2 To ws.Cells(Rows.Count, "A").End(xlUp).Row
            ws1.Copy After:=Sheets(Sheets.Count)
            With ActiveSheet
                .Name = ws.Cells(i, "A").Value
               End With
        Next i
        
End Sub

Open in new window

0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question