Roger, I ran your file and it immediately errored out on the JAN workbook.
After you Add the first sheet, you then delete the 3 original sheets created
with the workbook. Since my workbook options are set to create only 1 sheet
with each new workbook, your code could not do the delete and ran to your
error trap. Perhaps you should code your trap to delete all but the last
sheet, which you just added, something like For each ws in worksheets, If
ws.name <> "Jan", Then ws.Delete. That should cover any number of worksheet
option the user would set.
Mike F
"Roger Govier" <roger@technology4unospamdotcodotuk> wrote in message
news:(E-Mail Removed)...
> Hi Paolo
>
> I created a file for making Monthly workbooks with days of month as
> worksheets.
> It is available for download at
> http://excelusergroup.org/media/p/236.aspx
> See if the code there helps you in any way.
>
> --
> Regards
> Roger Govier
>
> "Paolo" <(E-Mail Removed)> wrote in message
> news:20AFBAC0-AF65-40E0-BDE0-(E-Mail Removed)...
>> I currently have a worksheet that uses VBA code which creates a worksheet
>> for
>> each day of the month using the MMM-d date format. It works fine this way
>> but
>> it would be better if I could get it to name each sheet as 1st through
>> 31st
>> NOT Jan-1 through Jan-31. A section of the code follows:
>>
>>
>> Do While i < 32 'counting 31 loops
>> If Month(firstday + i) = mon Then 'checking to see if 31st day is
>> still within the month
>> dayofweek = Weekday(firstday + i) 'retrieving day of the week from
>> date
>> currentday = firstday + i 'calculating loop date
>> currentday = Format(currentday, "mmm-d") 'formatting loop day for
>> tab
>> name
>> Select Case dayofweek 'choosing correct kind of
>> template
>> Case 1, 7 'weekend template
>> Sheets("Summer Weekend").Select 'select weekend template
>> Sheets("Summer Weekend").Copy Before:=Sheets(1) 'pasting
>> copy
>> as first
>> Sheets("Summer Weekend (2)").Select
>> Sheets("Summer Weekend (2)").Name = currentday 'changing
>> tab
>> name to loop date
>> Case 2, 3, 4, 5, 6 'weekday template
>> Sheets("Summer Weekday").Select
>> Sheets("Summer Weekday").Copy Before:=Sheets(1)
>> Sheets("Summer Weekday (2)").Select
>> Sheets("Sum
>