Bill,
Add a command button on your sheet and paste this code into the click
event. It checks for a valid date format, clears the old B5:CO6 area,
accounts for leap year and notes the days in a single letter configuration.
Give it a shot.
Roy
Dim StartMonth, Dayz, x As Integer
If IsDate(Range("A5")) = True Then
Range("B5:CO6").Select
Range("B5:CO6").ClearContents
Range("A5").Activate
StartMonth = Month(Range("A5"))
Select Case StartMonth
Case Is = 1, 12
Dayz = 90
Case Is = 2
Dayz = 89
Case Is = 3, 5, 6, 7, 8, 10, 11
Dayz = 92
Case Is = 4, 9
Dayz = 91
End Select
Select Case Month(Range("A5"))
Case Is = 12
x = (Year(Range("A5")) + 1) Mod 4
Case Is = 1, 2
x = Year(Range("A5")) Mod 4
End Select
If x = 0 Then Dayz = Dayz + 1
End If
Application.ScreenUpdating = False
For x = 1 To Dayz
Cells(5, x + 1).Value = Day(Range("A5") + x - 1)
Cells(5, x + 1).NumberFormat = "#"
Cells(6, x + 1).Value = Weekday(Range("A5") + x - 1)
Select Case Cells(6, x + 1).Value
Case Is = 1, 7
Cells(6, x + 1).Value = "S"
Case Is = 2
Cells(6, x + 1).Value = "M"
Case Is = 3, 5
Cells(6, x + 1).Value = "T"
Case Is = 4
Cells(6, x + 1).Value = "W"
Case Is = 6
Cells(6, x + 1).Value = "F"
End Select
Cells(6, x + 1).Value = Left(Cells(6, x + 1).Value, 1)
Next
Application.ScreenUpdating = True
"Bill" wrote:
> I need some help. I have a spredsheet that displays three months of dates.
>
> I place the start date in cell A5 like 1 Dec 04. Then starting in cloumn B5,
> the Date is place in the cell. In cell B6, the day is insert.
>
> EXAMPLE
>
> A5 = 1 Dec 04 then
> B5 = 1, and B6 = W for Wednesday
> C5 = 2, and C6 = T for Thursday
> D5 = 3, and D6 = F for Friday
>
> this sequence would need to continue until the through the third month. As
> in the case of this example it would need to continue through 28 Feb 05. Can
> anyone please provide me the VBA code to accomplishs this tasks.
>
> Thanks
>
> Bill
Bookmarks