|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub test()
Dim arr, brr
arr = Sheets("汇总表").Range("a1").CurrentRegion
n = (UBound(arr) - 3) * ((UBound(arr, 2) - 2) / 5)
ReDim brr(1 To n, 1 To 9)
For i = 3 To UBound(arr, 2) Step 5
k = k + 1
For j = 4 To UBound(arr)
h = h + 1
brr(h, 1) = k
brr(h, 2) = arr(2, i + 1)
brr(h, 3) = arr(2, i + 4)
brr(h, 4) = arr(j, 2)
brr(h, 5) = arr(j, i)
brr(h, 6) = arr(j, i + 1)
brr(h, 7) = arr(j, i + 2)
brr(h, 8) = arr(j, i + 3)
brr(h, 9) = arr(j, i + 4)
Next j
Next i
With Sheets("汇总表2")
.Range("a1").CurrentRegion.Clear
.Range("a1") = "序号"
.Range("b1") = "客户名称"
.Range("c1") = "编号"
.Range("d1") = "规格"
For i = 3 To 7
.Cells(1, i + 2) = Sheets("汇总表").Cells(3, i)
Next i
.Range("a2").Resize(UBound(brr), 9) = brr
End With
End Sub
|
|