Option Explicit
Sub TEST2()
Dim ar, br, i&, j&, r&
Application.ScreenUpdating = False
ar = Worksheets(1).[A1].CurrentRegion.Value
ReDim br(1 To UBound(ar) * UBound(ar, 2), 1 To 4)
For i = 2 To UBound(ar)
For j = 3 To UBound(ar, 2)
If Len(ar(i, j)) Then
r = r + 1
br(r, 1) = i - 1
br(r, 2) = ar(1, j)
br(r, 3) = ar(i, j)
End If
Next j
r = r + 1
br(r, 1) = i - 1 '
br(r, 2) = ar(i, 1)
br(r, 3) = ar(i, 2)
Next i
Cells.Clear
[A1].Resize(, 3) = Split("序号 项目 数量")
[A2].Resize(r, UBound(br, 2)) = br
Application.ScreenUpdating = True
Beep
End Sub
|