|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim hg(), lk()
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- With Worksheets("数据")
- r = .Cells(.Rows.Count, 3).End(xlUp).Row
- arr = .Range("a2:i" & r)
- End With
- With Worksheets("打印")
- .Cells.Clear
- End With
- m = 1
- n = 1
- With Worksheets("模板")
- ReDim hg(1 To 14)
- ReDim lk(1 To 12)
- For i = 1 To 14
- hg(i) = .Rows(i).RowHeight
- Next
- For j = 1 To 12
- lk(j) = .Columns(j).ColumnWidth
- Next
- For i = 1 To UBound(arr)
- .Range("c4") = arr(i, 4)
- .Range("c6") = arr(i, 6)
- .Range("c8") = arr(i, 3)
- .Range("c10") = arr(i, 5)
- .Range("j3") = arr(i, 7)
- .Range("k3") = arr(i, 8)
- .Range("l3") = arr(i, 9)
- .Range("a1:l14").Copy Worksheets("打印").Cells(m, n)
- If i Mod 2 = 1 Then
- For k = 1 To 14
- .Rows(m + k - 1).RowHeight = hg(k)
- Next
- End If
- n = n + 14
- If n > 15 Then
- n = 1
- m = m + 14
- End If
- Next
- End With
- With Worksheets("打印")
- For j = 1 To 12
- .Columns(j).ColumnWidth = lk(j)
- .Columns(j + 15).ColumnWidth = lk(j)
- Next
-
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|