Creation of sheets Day wise in a selected month

     

  • This template is very useful to note daily taks
  •  

  • It creates sheets from first date to selected date with simple click
  •  

  • We can create the sheets to entire month
  •  

    Private Sub ComboBox1_Enter()
    'Add Months to Combobox1
    Me.ComboBox1.Clear
    Dim i As Integer
    For i = 1 To 12
    ComboBox1.AddItem i
    Next
    End Sub

    Private Sub ComboBox2_Enter()
    Me.ComboBox2.Clear
    'Considered month from combobox1
    m = Me.ComboBox1.Value

    'Considered year from Textbox2
    Dim y As Integer
    ye = Me.TextBox2.Value

    i = 1
    y = Day(DateSerial(ye, m + i, 0))
    For d = 1 To y
    Me.ComboBox2.AddItem d
    Next
    End Sub

    Private Sub CommandButton1_Click()
    Unload Me
    End Sub

    Private Sub CommandButton2_Click()
    'If textbox3 is blank it asks for name and exists the sub
    If Me.TextBox3.Value = "" Then
    MsgBox "Please enter the Name"
    Exit Sub
    Me.TextBox3.SetFocus
    End If

    'Validation of Textbox2, which denotes about the year
    If Me.TextBox2.Value = "" Then
    MsgBox "Please enter the YEAR"
    Exit Sub
    Me.TextBox2.SetFocus
    End If

    'Define variabales for Date and year
    months = Me.ComboBox1.Value
    i = 1
    Dim years As Integer
    years = Me.TextBox2.Value

    'Create number of sheets for newly created workbook
    shcount = Me.ComboBox2.Value
    Application.SheetsInNewWorkbook = shcount + 1

    'Create new workbook Object variable and assign values
    Dim wkb As Workbook
    Set wkb = Workbooks.Add
    wkb.Activate

    'Loop all the sheets in newly created workbook
    For i = 1 To shcount
    shname = MonthName(months) & i
    With wkb.Sheets(i + 1)
    .Activate
    .Name = shname 'Add sheet name
    .Columns("L:xfd").EntireColumn.Hidden = True ' Hide the columns
    .Range("G2").Value = DateSerial(years, months, i) 'Add the date in G2 cell
    .Range("G2").Select
    Selection.NumberFormat = "[$-F800]dddd, mmmm dd, yyyy"
    .Range("G2:J2").Select 'Format the G2 cell
    With Selection
    .HorizontalAlignment = xlCenterAcrossSelection
    .Font.Size = 21
    .Font.Name = "High Tower Text"
    .Font.ColorIndex = 3
    End With
    'Add the heading for each and every page and format
    Range("B5").Value = "Hi" & " " & TextBox3.Value & " " & "Update today's tasks"
    Range("B5:J5").Select
    With Selection
    .HorizontalAlignment = xlCenterAcrossSelection
    .Font.Size = 20
    .Font.ColorIndex = 5
    .Font.Name = "FootlightMT Light"
    .Font.Bold = True
    End With
    End With
    ActiveWindow.DisplayGridlines = False
    d = d + 1
    Next
    'Unload the userform
    Unload Me
    'Add the sheet names in first sheet and provide hyperlink
    Dim sh1 As Worksheet
    Set sh1 = wkb.Sheets("Sheet1")
    sh1.Activate
    With sh1
    .Columns("L:xfd").EntireColumn.Hidden = True
    End With
    ActiveWindow.DisplayGridlines = False
    sh1.Name = "Index"
    For i = 1 To wkb.Sheets.Count
    sh1.Range("A" & i).Activate
    sh1.Range("A" & i).Value = Sheets(i).Name
    ActiveCell.Hyperlinks.Add anchor:=sh1.Cells(i, 1), Address:="", _
    SubAddress:=Sheets(i).Name & "!A1", _
    ScreenTip:="Hi click here to view the sheet"
    With ActiveCell
    .Font.Size = 15
    .Font.ColorIndex = 5
    .Font.Name = "FootlightMT Light"
    .HorizontalAlignment = xlCenter
    .Columns.AutoFit
    End With
    Next

    Application.SheetsInNewWorkbook = 3

    End Sub


    Private Sub DateUpTo_Enter()
    Dim dd As Integer
    dd = Me.ComboBox2.Value
    Dim yyyy As Integer
    yyyy = Me.TextBox2.Value
    Dim mm As Integer
    mm = Me.ComboBox1.Value
    j = DateSerial(yyyy, mm, dd)
    DateUpTo.Value = j
    End Sub

     



     

    Download The Workbook