|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim rq1 As Date
- Dim rq2 As Date
- Dim rq As Date
- With Worksheets("sheet1")
- rq1 = .Range("a2")
- rq2 = .Range("b2")
- r = .Cells(.Rows.Count, 5).End(xlUp).Row
- arr = .Range("d2:e" & r)
- arr(1, 1) = rq1
- arr(UBound(arr), 1) = rq2
- n1 = CLng(rq1)
- n2 = CLng(rq2)
- For i = 2 To UBound(arr) - 1
- n = n1 + Int(Rnd() * (n2 - n1 + 1))
- arr(i, 1) = CDate(n)
- Next
- .Columns(4).NumberFormatLocal = "m月d日"
- .Range("d2").Resize(UBound(arr), 2) = arr
- End With
- End Sub
复制代码 |
|