Inserting Worksheets

Closed
Neo - 27 May 2010 à 10:51
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 27 May 2010 à 16:49
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 response

rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 766
27 May 2010 à 16:49
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