You could use a macro approach. e.g.
Sub Test()
MyYear = Application.InputBox("Please enter year", "Select year", Year(Now()), , , , , 1)
RowsPerWeek = 7 ' or 8?
For N = 11 To 12 ' change to 1 to 12
ValidDate = True
MyWeekNumber = WorksheetFunction.WeekNum(DateValue(1 & "/" & N & "/" & MyYear), 1)
WorkingDayCount = 0
Select Case N
'Add other months here
Case Is = 11
TargetSheet = "NOV"
Case Is = 12
TargetSheet = "DEC"
End Select
StartRow = 6
For M = 1 To 31
On Error GoTo NonValidDate
MyWeekday = Weekday(DateValue(M & "/" & N & "/" & MyYear), vbSunday)
If ValidDate = True Then
WeekWithinMonth = WorksheetFunction.WeekNum(DateValue(M & "/" & N & "/" & MyYear), 1) - MyWeekNumber
Sheets(TargetSheet).Cells(StartRow + (RowsPerWeek * (WeekWithinMonth)), (MyWeekday * 2) - 1) = M
If MyWeekday >= 2 And MyWeekday <= 6 Then
WorkingDayCount = WorkingDayCount + 1
Sheets(TargetSheet).Cells(StartRow + (RowsPerWeek * (WeekWithinMonth)), (MyWeekday * 2)) = WorkingDayCount
End If
End If
Next M
Next N
Exit Sub
NonValidDate:
ValidDate = False
Resume Next
End Sub
This should deal with leap years. You will need to have the same number of rows per week - you seem to have 7 for NOV and 8 for DEC.
Open up the VBA editor by hitting ALT F11
Insert a new module by hitting Insert - Module
Paste the macro into the empty sheet
Hit ALT F11 to get back to the worksheet.
Run the macro by going to tools-macro in Excel 2003 or the view ribbon in Excel 2007.
Bookmarks