Supervisor log sheet for each day of the month.

stolenweasel

New Member
Joined
May 29, 2023
Messages
8
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I have a sheet that I am trying to automate that we use for each day of the month. Right now we have a seperate file for each day that contains one sheet/tab. The sheet is dated in the top right in cell H2. I would like the script to populate either a new file per day with the name of the file being mm dd yy and also populating the corresponding date in H2 for each day. Im not opposed to one file for the month with 28+ days as tabs. The tabs would need to copy the sheet, be named for the dates and also rename H2 to the corresponding date.
 

Attachments

  • 20230529_040320.jpg
    20230529_040320.jpg
    163 KB · Views: 12
  • 20230529_040336.jpg
    20230529_040336.jpg
    177.1 KB · Views: 12
  • 20230529_040403.jpg
    20230529_040403.jpg
    179.5 KB · Views: 10

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Also one more thing it needs to have a date picker that will create a whole year worth or a month at a time, either way is fine.

Thanks in advance.
 
Upvote 0
Please post a copy of your example workbook to a download website (DropBox.com, etc).
 
Upvote 0
Please post a copy of your example workbook to a download website (DropBox.com, etc).
Thank you for the reply, when i go to work this evening i will see if i can make that work. I work graveyard so you should see it in the morning. I dont use Dropbox or anything like that much so i will have to revive that knowledge.
 
Upvote 0
Yes, the link is successful. Reviewing the workbook layout now. Will let you know something in a day or so.
 
Upvote 0
Yes, the link is successful. Reviewing the workbook layout now. Will let you know something in a day or so.
So i found something similar on this site. I tweaked it to fit what i need. This appears to work. Is there better options than this? Thanks again for your help.



Sub ANIMATE_SUPLOG()
Application.ScreenUpdating = False
Dim Mth As Long, dy As Long, DaysInMonth As Long, yr As String, srcWS As Worksheet
Set srcWS = ThisWorkbook.Sheets("Template") 'Name of worksheet that will be compiled to new workbook
askyear:
yr = InputBox("Enter the Year number required" _
& vbCrLf & "in the format of YYYY e.g. " & "2023" _
& vbCrLf & "" _
, "Enter Year Number")
If yr = "" Or Val(yr) = 0 Then Exit Sub
If Val(yr) < 1999 Or Val(yr) > 2100 Then
GoTo askyear
End If
For Mth = 1 To 12
DaysInMonth = DateSerial(yr, Mth + 1, 1) - DateSerial(yr, Mth, 1)
srcWS.Copy
For dy = 1 To DaysInMonth
Sheets(1).Copy After:=Sheets(Sheets.Count)
With ActiveSheet
.Name = Format(DateSerial(yr, Mth, dy), "dd MMM yy")
.Range("H2") = Format(DateSerial(yr, Mth, dy), "dd MMMM yyyy")
End With
Next dy
Application.DisplayAlerts = False
Sheets(1).Delete
Application.DisplayAlerts = True
With ActiveWorkbook
.SaveAs ThisWorkbook.Path & Application.PathSeparator & "Sup Log " & Format(Mth, "00") & " " & MonthName(Mth) & " " & yr & ".xlsx", FileFormat:=51
.Close False
End With
Next Mth
Application.ScreenUpdating = True
End Sub
 
Upvote 0
VBA Code:
Option Explicit

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")
    Next i
EndIt:
    Application.ScreenUpdating = True
End Sub


Paste the following in the ThisWorkbook module :

Code:
Option Explicit

Private Sub Workbook_Open()
    On Error Resume Next
    Sheets(Format(Date, "ddd mmm dd")).Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,216
Messages
6,123,669
Members
449,114
Latest member
aides

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