try this:
- Sub zz()
- Application.ScreenUpdating = 0
- Dim ar, xm$, a, b(), n&
- xm = Right(Sheets(1).[b1], 2)
- ar = Sheets(1).UsedRange
- For j = 1 To UBound(ar, 2)
- If InStr(ar(1, j), xm) Then a = a & "|" & j
- Next
- a = Split(a, "|")
- ReDim b(1 To (UBound(ar) - 1) * UBound(a) + 1, 1 To 6)
- For j = 1 To 6
- b(1, j) = ar(1, j)
- Next
- n = 1
- For i = 2 To UBound(ar)
- n = n + 1
- For j = 1 To 6
- b(n, j) = ar(i, j)
- Next
- For j = 1 To UBound(a)
- If Len(ar(i, a(j))) Then
- n = n + 1
- For jj = 0 To 2
- b(n, jj + 2) = ar(i, a(j) + jj)
- Next
- b(n, 5) = ar(i, 5): b(n, 6) = ar(i, 6)
- End If
- Next
- Next
- Workbooks.Add 1
- [a1].Resize(n, 6) = b
- Application.ScreenUpdating = 1
- End Sub
复制代码
|