|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test1() '参与练习
- Dim ar, br, cr, alColl As Object
- Dim y As Long, m As Long, d As Long
- Dim start_ As Long, end_ As Long
-
- d = 21
- Set alColl = CreateObject("System.Collections.ArrayList")
-
- br = Range("E3", Cells(Rows.Count, "E").End(xlUp).Offset(1)).Value
- For y = 1 To UBound(br) - 1
- If Day(br(y, 1)) <> d Then alColl.Add br(y, 1)
- Next
-
- cr = Range("B3:B4").Value
- alColl.Add cr(1, 1)
- alColl.Add cr(2, 1)
-
- start_ = Val(Format(cr(1, 1), "yyyymm"))
- end_ = Val(Format(cr(2, 1), "yyyymm"))
-
- For y = Year(cr(1, 1)) To Year(cr(2, 1))
- For m = 1 To 12
- If Val(y & Format(m, "00")) >= start_ Then
- If Val(y & Format(m, "00")) <= end_ Then
- If DateSerial(y, m, d) < cr(2, 1) Then alColl.Add DateSerial(y, m, d)
- End If
- End If
- Next
- Next
- alColl.Sort
- ar = WorksheetFunction.Transpose(alColl.ToArray)
-
- With Range("H3")
- .CurrentRegion.ClearContents
- .Resize(, 2) = Split("日期点 天数")
- .Offset(1).Resize(UBound(ar)).Value = ar
- End With
-
- Set alColl = Nothing
- Beep
- End Sub
复制代码 |
|