Inserting Worksheets

Closed
Neo - May 27, 2010 at 10:51 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - May 27, 2010 at 04:49 PM
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 January 28, 2010 Status Contributor Last seen May 5, 2022 766
May 27, 2010 at 04:49 PM
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
0