• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Specify Sheet

Tech56

Member
Hi,

Does someone know how to change the code to specify worksheet 'Template' instead of active sheet?

Thanks

Code:
Sub Create()

    Dim i As Long
    Dim xNumber As Integer
    Dim xName As String
    Dim xActiveSheet As Worksheet
    On Error Resume Next
    Application.ScreenUpdating = False
    Set xActiveSheet = ActiveSheet
    xNumber = InputBox("Enter number of times to copy the current sheet")
    For i = 1 To xNumber
        xName = ActiveSheet.Name
        xActiveSheet.Copy After:=ActiveWorkbook.Sheets(xName)
        ActiveSheet.Name = "R-" & i
    Next
    xActiveSheet.Activate
    Application.ScreenUpdating = True
    Call ListSheets
    
End Sub
 
Hi,​
the best is to use the sheet's CodeName if the code is located in the same workbook or use the sheet's name like Sheets("name") …​
 
I can't do nothing with such a 'code' and I won't guess anything ! Just use the sheet reference when you need …​
Another way to learn is to activate the Macro Recorder and operate manually : you will get your own starter.​
 
I want to copy the sheet 'Template' multiple times and name the new sheets R-1, R-2, etc.

Can you derive a code since you don't like the one I provided?

Thank you
 
Hi I found this one but it doesn't name the sheets:

Code:
Sub Copier ()
Dim x As Integer
x = InputBox("Enter number of times to copy Template")
For numtimes = 1 To x
ActiveWorkbook.Sheets("Template").Copy _
After:=ActiveWorkbook.Sheets("Template")
Next
End Sub
 
Back
Top