View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
hungledink[_3_] hungledink[_3_] is offline
external usenet poster
 
Posts: 1
Default Creating a worksheet for every weekday


This works well thanks a lot

Peter T;4044992 Wrote:
You can temporarily change Application.DisplayAlerts = False / True.

This revised routine avoids deleting any sheets and leaves th
'ordered'
sheet codenames intact.

Sub Test3()
Dim dFrom As Date, dTo As Date
Dim d As Date, i As Long

dFrom = CDate("1/Jan/07")
dTo = CDate("31/Dec/07")
dTo = dFrom + 30 ' limit for testing

Workbooks.Add
n = 0
For d = dFrom To dTo
If Weekday(CDate(d), 2) < 6 Then
n = n + 1
If Worksheets.Count < n Then
Worksheets.Add(after:=Worksheets(n - 1)).Name = Format(d, "yymmmd
ddd")
Else
Worksheets(n).Name = Format(d, "yymmmdd ddd")
End If
End If
Next

Worksheets(1).Activate
End Sub

I amended the date format from last time but adjust to your needs.

Regards,
Peter T



Thanks also to Tom, your help is appreciated

--
hungledin
-----------------------------------------------------------------------
hungledink's Profile: http://www.officehelp.in/member.php?userid=556
View this thread: http://www.officehelp.in/showthread.php?t=128881

Posted from - http://www.officehelp.i