hebehemonkey
New Member
- Joined
- Oct 12, 2017
- Messages
- 3
Hi Everyone,
I have to create 79 tabs in excel using a standard template [see below], but that references sequential values in a separate worksheet. We will call the template worksheet "Template" and the worksheet that contains the reference values "Reference". I need help creating a macro to do the following:
I tried to start something, but my skills (and knowledge of the correct vocabulary) have my hopelessly lost. Can anyone help?
Sub CopyWorkSheets()
Dim xNumber As Integer
Dim xWsName As String
On Error Resume Next
xTitleId = "Enter Value"
xWsName = Application.InputBox("Copy worksheet name", xTitleId, , Type:=2)
xNumber = Application.InputBox("Copy number", xTitleId, , Type:=1)
For i = 1 To xNumber
Application.ActiveWorkbook.Sheets(xWsName).Copy _
After:=Application.ActiveWorkbook.Sheets(xWsName)
Next
End Sub
I have to create 79 tabs in excel using a standard template [see below], but that references sequential values in a separate worksheet. We will call the template worksheet "Template" and the worksheet that contains the reference values "Reference". I need help creating a macro to do the following:
- Copy the template 79 times.
- Name each new worksheet according to the sequential rows in column F of "Reference" (so the first copy of "Template" would have a name defined in F3 in the "Reference" sheet. the second copy of "Template" would have a name defined by F4, etc. etc. etc).
- Set the values of cells in the new worksheets (i.e. the copies of "Template") equal to sequential rows in Column A, B, C, D, E of the worksheet "Reference", such that copy 1 of the "Template" references cells A3, B3, C3, D3 and E3; copy 2 of the "Template" references cells A4, B4, C4, D4, E4; etc.
I tried to start something, but my skills (and knowledge of the correct vocabulary) have my hopelessly lost. Can anyone help?
Sub CopyWorkSheets()
Dim xNumber As Integer
Dim xWsName As String
On Error Resume Next
xTitleId = "Enter Value"
xWsName = Application.InputBox("Copy worksheet name", xTitleId, , Type:=2)
xNumber = Application.InputBox("Copy number", xTitleId, , Type:=1)
For i = 1 To xNumber
Application.ActiveWorkbook.Sheets(xWsName).Copy _
After:=Application.ActiveWorkbook.Sheets(xWsName)
Next
End Sub