|
Sub test()
Sheets("销货单").UsedRange.Offset(11).Clear
ar = Sheets("数据").[a1].CurrentRegion
With Sheets("销货单")
y = 12
For i = 2 To UBound(ar) - 2
.Rows("1:11").Copy .Cells(y, 1)
y = y + 11
Next i
m = 1
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
n = 1
.Cells(m + 2, 2) = ar(i, 1)
.Cells(m + 3, 2) = ar(i, 2)
.Cells(m + 4, 2) = ar(i, 3)
.Cells(m + 5, 2) = ar(i, 4)
.Cells(m + 6, 2) = ar(i, 5)
.Cells(m + 7, 2) = ar(i, 6)
For j = 7 To UBound(ar, 2) Step 3
.Cells(m + 2 + n, 4) = ar(i, j)
.Cells(m + 2 + n, 5) = ar(i, j + 1)
.Cells(m + 2 + n, 6) = ar(i, j + 2)
n = n + 1
Next j
m = m + 11
End If
Next i
End With
End Sub
|
|