|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr, zrr()
- With Worksheets("数据")
- r = .Cells(.Rows.Count, 6).End(xlUp).Row
- arr = .Range("d2:l" & r)
- End With
- xm = ""
- For i = 1 To UBound(arr)
- If arr(i, 1) & "+" & arr(i, 2) <> xm Then
- m = m + 1
- ReDim Preserve zrr(1 To 2, 1 To m)
- zrr(1, m) = i
- zrr(2, m) = i
- xm = arr(i, 1) & "+" & arr(i, 2)
- Else
- zrr(2, m) = i
- End If
- Next
- With Worksheets("明细")
- m = 4
- For k = 1 To UBound(zrr, 2)
- zys = Application.Ceiling((zrr(2, k) - zrr(1, k) + 1) / 19, 1)
- fys = 0
- For i = zrr(1, k) To zrr(2, k)
- If m = 4 Then
- .Range("b2:c2,a5:h22,a23:h24") = ""
- .Range("b2") = arr(i, 1)
- .Range("c2") = arr(i, 2)
- End If
- For j = 3 To UBound(arr, 2)
- .Cells(m, j - 2) = arr(i, j)
- Next
- m = m + 1
- If i = zrr(2, k) Then
- .Range("a23") = "申报依据:XXX XXX"
- .Range("g23") = "登记时间:" & Format(Date, "yyyy年mm月dd日")
- .Range("a24") = "填表人:"
- End If
- If m > 22 Or i = zrr(2, k) Then
- fys = fys + 1
- With .PageSetup
- .CenterFooter = "第" & fys & "页 共" & zys & "页"
- End With
- .PrintOut
- m = 4
- End If
- Next
- Next
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|