Create Multiple workbooks, with multiple workshhets, containing a template

ASPOS

New Member
Joined
Dec 7, 2018
Messages
1
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:

Sub AddMultiSheetswithNames()

Worksheets.Add after:=Sheet1, Count:=20

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
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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)
    Workbooks.Add
    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
                ActiveWorkbook.Sheets.Add.Name = 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
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top