Results 1 to 9 of 9

Macro to Create Dated Worksheets

Threaded View

  1. #4
    Registered User
    Join Date
    08-28-2010
    Location
    Baltimore, Maryland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Macro to Create Dated Worksheets

    Thanks for the responses guys. I'm not actually analyzing data really, its a daily activity report for my friend that works at the Ritz Carlton. Here was a macro that I found that does what I want, except 1: It doesn't Create the Sheets in the same workbook, it creates a new one and 2: I had previously tried the mid formula above to reference the sheet name in the cell, but I got a #VALUE error.
    Option Explicit
    Sub testme()
       Dim iCtr As Long
       Dim NewWkbk As Workbook
       Dim HowMany As Long
       Dim StartDate As Date
       
       StartDate = DateSerial(Year(Date), Month(Date) + 1, 1)
       StartDate = Application.InputBox _
                   (prompt:="Enter a date in the month you want", _
                   Type:=1, Default:=Format(StartDate, "mmmm dd, yyyy"))
     
       If Year(StartDate) < 2005 _
        Or Year(StartDate) > 2010 Then
           Exit Sub
       End If
       'First of the month!
       StartDate = DateSerial(Year(StartDate), Month(StartDate), 1)
       HowMany = Day(DateSerial(Year(StartDate), Month(StartDate) + 1, 0))
       
       Set NewWkbk = Workbooks.Add(1) 'single sheet
       NewWkbk.Sheets.Add Count:=HowMany - 1
             
       For iCtr = 1 To HowMany
           NewWkbk.Worksheets(iCtr).Name _
               = Format(StartDate - 1 + iCtr, "yyyy_mm_dd")
       Next iCtr
           
    End Sub
    This one actually only created tabs by month, but that is fine. My friend just wants do create each month at a time without a whole lot of work because the employees using the spreadsheet aren't good with excel, so he didn't want to have them have to copy the sheets each day and set them up.

    I attached a copy of the sheet that I want to duplicate
    Attached Files Attached Files
    Last edited by Noah.Pielert; 08-28-2010 at 04:33 PM. Reason: deleted quote

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1