SereneSea
New Member
- Joined
- Feb 2, 2022
- Messages
- 43
- Office Version
- 2016
- Platform
- Windows
Hi all,
I hope you can help me:
I am trying to create a template and use VBA code. I have two sheets, one that is a "template" and second is "master". The user will input data in the master and then use a VBA code to copy and paste the "template" as many times as needed and then name the sheet with the Title from the master sheet and use add the subtitle info in A3 going down the list in the master until a blank cell is found.
Master sheet:
and
template:
The code for copying and naming spreadsheet is below, but it is currently creating sheets from both A column and B Column. I only need A column to be in A2 (Title) and sheet name, and the B column info to be used in A3 (subtitle). Hope you can help me!
I hope you can help me:
I am trying to create a template and use VBA code. I have two sheets, one that is a "template" and second is "master". The user will input data in the master and then use a VBA code to copy and paste the "template" as many times as needed and then name the sheet with the Title from the master sheet and use add the subtitle info in A3 going down the list in the master until a blank cell is found.
Master sheet:
Template.xlsm | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | Title | Subtitle | ||||
2 | Cats | siamese | ||||
3 | Dog | German shepard | ||||
4 | Bird | Pigeon | ||||
5 | ||||||
6 | ||||||
7 | ||||||
8 | ||||||
9 | ||||||
10 | ||||||
Master |
and
template:
Template.xlsm | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | |||
1 | ||||||||||||
2 | Title | Information | ||||||||||
3 | Subtitle | |||||||||||
4 | ||||||||||||
5 | ||||||||||||
6 | ||||||||||||
7 | ||||||||||||
8 | ||||||||||||
9 | ||||||||||||
10 | ||||||||||||
11 | ||||||||||||
12 | ||||||||||||
13 | ||||||||||||
14 | ||||||||||||
15 | ||||||||||||
16 | ||||||||||||
17 | ||||||||||||
18 | ||||||||||||
19 | ||||||||||||
20 | ||||||||||||
21 | ||||||||||||
22 | ||||||||||||
23 | ||||||||||||
24 | ||||||||||||
Template |
The code for copying and naming spreadsheet is below, but it is currently creating sheets from both A column and B Column. I only need A column to be in A2 (Title) and sheet name, and the B column info to be used in A3 (subtitle). Hope you can help me!
VBA Code:
Sub makeSheets()
Dim sh1 As Worksheet, sh2 As Worksheet, c As Range
Set sh1 = Sheets("Template")
Set sh2 = Sheets("Master")
For Each c In sh2.Range("A2", sh2.Cells(Rows.Count, 2).End(xlUp))
sh1.Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = c.Value: ActiveSheet.Range("A2") = c.Value
Next
End Sub