+ Reply to Thread
Results 1 to 3 of 3

Creating an Excel Template for each month

Hybrid View

Gsugihara Creating an Excel Template... 09-14-2022, 10:02 PM
Toonies Re: Creating an Excel... 09-15-2022, 02:27 AM
Gsugihara Re: Creating an Excel... 09-20-2022, 10:38 PM
  1. #1
    Registered User
    Join Date
    09-14-2022
    Location
    Honolulu, HI
    MS-Off Ver
    2016
    Posts
    4

    Creating an Excel Template for each month

    i'm getting an error (upload failed) trying to upload an example. basically i have a workbook for September and the worksheet tabs at the bottom are labeled Thursday Sept 1, Friday Sept 2, and so on until the end of the month. i tried googling code to automate this via vba but have failed. could i please get some help with this?

    aloha,

    Gavin

  2. #2
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    512

    Re: Creating an Excel Template for each month

    Hi have a look at this it should do what your looking for

    https://www.mrexcel.com/board/thread...-month.674087/

    Sub CreateSheets()
    Dim strDate As String
    Dim NumDays As Long
    Dim i As Long
    Dim sh As Object
    Dim wsBase As Worksheet
    On Error GoTo EndIt
        
    ' The Do statement to captures Month/Year via Input Box
    ' and return number of days in the month to the NumDays variable
        Do
            strDate = Application.InputBox( _
                Prompt:="Please enter month and year: mm/yyyy", _
                Title:="Month and Year", _
                Default:=Format(Date, "mm/yyyy"), _
                Type:=2)
     
            If strDate = "False" Then Exit Sub
            If IsDate(strDate) Then Exit Do
            If MsgBox("Please enter a valid date, such as ""01/2010""." _
                & vbLf & vbLf & "Shall we try again?", vbYesNo + vbExclamation, _
                "Invalid Date") = vbNo Then End
        Loop
        
        Application.ScreenUpdating = False
        NumDays = Day(DateSerial(Year(strDate), Month(strDate) + 1, 0))
        Set wsBase = Sheets("Template")
        
    ' For each day, the For statement below copies the template sheet 'n' times
        For i = 1 To NumDays
            wsBase.Copy After:=Sheets(Sheets.Count)
            ActiveSheet.Name = Format(DateSerial(Year(strDate), Month(strDate), i), "ddd mmm dd yyyy")
        Next i
    EndIt:
        Application.ScreenUpdating = True
    End Sub

  3. #3
    Registered User
    Join Date
    09-14-2022
    Location
    Honolulu, HI
    MS-Off Ver
    2016
    Posts
    4

    Re: Creating an Excel Template for each month

    that worked like a charm!! thank you so much!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 11-13-2017, 01:36 AM
  2. Replies: 1
    Last Post: 09-28-2017, 11:00 AM
  3. excel 2003 template 12 month 13 column
    By jeanvallery in forum Excel General
    Replies: 1
    Last Post: 03-22-2012, 08:42 PM
  4. I Need Help Creating or Finding an Excel Template
    By mscraven in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-13-2006, 10:30 PM
  5. Help about creating excel using template.
    By qwert in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-07-2006, 07:35 AM
  6. [SOLVED] Help about creating excel using template.
    By qwert in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-07-2006, 07:30 AM
  7. [SOLVED] Creating a template in Excel?
    By KGreen in forum Excel General
    Replies: 1
    Last Post: 09-21-2005, 01:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1