Sub 复制()
Dim arr, i%, brr(), k%, m%, n%, j%
Sheet2.Cells.ClearContents
arr = Sheet1.Range("A1").CurrentRegion
For i = 2 To UBound(arr, 1)
k = k + arr(i, 6)
Next
ReDim brr(1 To k + UBound(arr, 1), 1 To 5)
brr(1, 1) = arr(1, 1)
brr(1, 2) = arr(1, 2)
brr(1, 3) = arr(1, 3)
brr(1, 4) = arr(1, 4)
brr(1, 5) = arr(1, 5)
j = 0
For m = 2 To UBound(arr, 1)
For n = 1 To arr(m, 6) + 1
brr(j + n + 1, 1) = arr(m, 1)
brr(j + n + 1, 2) = arr(m, 2)
brr(j + n + 1, 3) = arr(m, 3)
brr(j + n + 1, 4) = arr(m, 4)
brr(j + n + 1, 5) = arr(m, 5)
Next
j = j + n - 1
Next
Sheet2.Range("A1").Resize(k + UBound(arr, 1), 5) = brr
End Sub
|