|
Sub Macro1()
On Error Resume Next
Dim arr, i%, j%
Sheets("设置").Activate
arr = [b2:b13]: y = [a2]
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each sh In Sheets
If sh.Name <> "设置" Then sh.Delete
Next
For i = 1 To UBound(arr)
If Sheets("" & arr(i, 1)) Is Nothing Then
With Sheets.Add(after:=Sheets(Sheets.Count))
d = Day(DateSerial(y, i + 1, 0))
.Cells(2, 1) = "日期": .Cells(2, 2) = "星期"
For j = 1 To d
rq = DateSerial(y, i, j)
.Cells(j + 2, 1) = rq
.Cells(j + 2, 2) = "星期" & Replace(Application.Text(Weekday(rq, 2), "[dbnum1]"), "七", "日")
If Weekday(rq, 2) = 6 Or Weekday(rq, 2) = 7 Then .Cells(j + 2, 2).Interior.ColorIndex = 3
* .Cells(j + 2, 3) = DatePart("ww", rq, 2) '每周周一为开始
Next
.Columns.AutoFit
.Name = arr(i, 1)
End With
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
|
|