|
请测试:- Sub 宏1()
- Dim MyDate As Date, MyYear%, MyMonth%, l%, lastday%
- Dim arr, brr(), d As Object
- Set d = CreateObject("scripting.dictionary")
- MyYear = [c3]
- MyMonth = [h3]
- MyDate = DateSerial(MyYear, MyMonth, 1)
- [b3] = Application.Text(MyDate, "mmm")
- f = Weekday(DateSerial(MyYear, MyMonth, 1))
- lastday = Day(DateSerial(MyYear, MyMonth + 1, 0))
- ReDim brr(1 To Application.RoundUp((f + lastday - 1) / 7, 0) * 2, 1 To 7)
- arr = Sheets("总表").[a1].CurrentRegion
- For i = 3 To UBound(arr)
- d(arr(i, 3)) = d(arr(i, 3)) & Chr(10) & arr(i, 2)
- Next
- n = Weekday(DateSerial(MyYear, MyMonth, 1)) - 1
- For i = 1 To lastday
- n = n + 1
- If n > 7 Then
- n = 1
- m = m + 2
- End If
- brr(m + 1, n) = DateSerial(MyYear, MyMonth, i)
- If d.Exists(brr(m + 1, n)) Then brr(m + 2, n) = Mid(d(brr(m + 1, n)), 2)
- Next
- Range("B5:H16").ClearContents
- [b5].Resize(UBound(brr), 7) = brr
- End Sub
复制代码 |
|