|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- With Worksheets("成绩统计表")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a4:j" & r)
- End With
- ReDim brr(1 To UBound(arr) * 6, 1 To 6)
- m = 0
- For i = 2 To UBound(arr)
- m = m + 1
- brr(m, 1) = "2018.5.7-5.11"
- brr(m, 2) = "理论"
- brr(m, 3) = 40
- brr(m, 4) = "脱产"
- brr(m, 5) = arr(i, 5)
- brr(m, 6) = arr(i, 2)
- For j = 6 To UBound(arr, 2)
- m = m + 1
- brr(m, 2) = arr(1, j)
- brr(m, 5) = arr(i, j)
- Next
- Next
- With Worksheets("打印")
- .Cells.Clear
- .Range("a1").Resize(m, UBound(brr, 2)) = brr
- For i = 1 To m Step 6
- For Each y In Array(1, 3, 4, 6)
- .Cells(i, y).Resize(6, 1).Merge
- Next
- Next
- .Range("a1:f" & m).Borders.LineStyle = xlContinuous
- With .UsedRange
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- End Sub
复制代码 |
|