Inserting Worksheets

[Closed]
Report
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
Hello,

Is there a way to automatically insert a new sheet in excel each day ? If yes, can the new sheets be formatted as the original sheet and also be renamed. eg. todays sheet will be called May 27 Am, the next sheet will be called May 27 Pm, then May 28th Am, etc..

I do not want the weekend dates included.

Please and Thanks

1 reply

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
Yeah. You have to add a code to book. So when ever you open the book it looks if the sheet for that day is there or not. If not, it adds one

1. Press ALT + F11
2. PRESS CTRL + R
3. Double click on "ThisWorkbook"
4. Paste the code

Private Sub Workbook_Open()
Dim sTodaySheet As String

    
    Err.Clear
    
    sTodaySheet = Format(Now, "YYYY MM DD")
    On Error Resume Next
    
        Sheets(sTodaySheet).Select
           
    On Error GoTo 0
    
     If ActiveSheet.Name = sTodaySheet Then Exit Sub
     
     Sheets.Add
     ActiveSheet.Name = sTodaySheet
    
End Sub