# Create Multiple workbooks, with multiple workshhets, containing a template

#### ASPOS

##### New Member
Need help to solve a tricky situation:

I have an workbook with two sheets: "sheet1" containing on column A the working days of a year and on column B the months of a year and sheet "Template", which contains a template (with formulas in it).

(1)By clicking a button I want to (2) create 12 workbooks (1 for each month of the year), each workbook (3) having between 19 and 23 worksheets (depends how many working days are in a month). Also the workbook has to (4) have the name of the month and the (5) name of the worksheets has to be copied from the values contained in the column A. (for example, the first workbook has to have the name "January" and has to have 22 worksheets, with the name "03.01.2019", "04.01.2019" ..."31.01.2019"). Also, (6) in each worksheet I need the template from the "Template" sheet in the "master" workbook.

I'm new to VBA, tried different approaches (found here, on this forum) of this problem, but haven't been able to solve it yet. So far I managed to create a workbook with multiple sheets, each having the name of the day.

Any help is much appreciated. Thank you in advance.

Here is what I managed so far:

Dim p, q As Integer

Dim sheetname

sheetname = Array("03.01.2019", "04.01.2019", "07.01.2019", "08.01.2019", "09.01.2019", "10.01.2019", "11.01.2019", "14.01.2019", "15.01.2019", "16.01.2019", "17.01.2019", "18.01.2019", "21.01.2019", "22.01.2019", "23.01.2019", "25.01.2019", "28.01.2019", "29.01.2019", "30.01.2019", "31.01.2019")

p = Worksheets.Count

For q = 1 To p
With Worksheets(q)

'sheetname = InputBox("Enter name for worksheet")

.Name = sheetname(q)
End With
Next q
End Sub

I also found a code for copying data from a worksheet to another, but haven't figure it out how to integrate it in the code above

Sub CopySeriesToNewSheet(src As Worksheet, Start As Long, Last As Long, _
name As String)

Dim wb As Workbook : Set wb = Workbooks.Add
Dim tgt As Worksheet

Set tgt = wb.Sheets(1)
tgt.name = name

src.Range("A" & Start & ":N" & Last).Copy
tgt.Range("A1:N" & Last).PasteSpecial xlPasteAll
wb.SaveAs name
wb.Close
End Sub

#### ravishankar

##### Well-known Member
change file path and run the macro
Code:
``````Sub newyear()
Dim x As String
Dim a As Long, d As Long, c As Long
For a = 1 To 12
x = MonthName(a)
b = Choose(a, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
For c = 1 To b
d = Weekday(c & "/" & a & "/" & 2019)
If d <> 1 And d <> 7 Then
MsgBox d & "  " & c
End If
Next c
ActiveWorkbook.SaveAs Filename:="C:\excelmacro\" & x & ".xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
Next a
MsgBox "complete"
End Sub``````
this will get you started.
ravishankar

1,082,246
Messages
5,363,995
Members
400,772
Latest member
solbebe

### This Week's Hot Topics

• populate from drop list with multiple tables
Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
• Find list of words from sheet2 in sheet1 before a comma and extract text vba
Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
• Dynamic Formula entry - VBA code sought
Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...