?
Solved

Make multiple copies of a worksheet in an Excel file

Posted on 2014-03-26
4
Medium Priority
?
314 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 52

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
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‚Ķ

762 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