|
是不是要这样?
- Sub test()
- Dim Arr, i&, j&, k&, x&, m&
- Arr = Sheet1.[a2].Resize(Sheet1.[a1].CurrentRegion.Rows.Count - 1, 12)
- ReDim Brr(1 To UBound(Arr, 1) * 3, 1 To 5)
- x = 0
- For i = 1 To UBound(Arr, 1)
- For j = 1 To UBound(Arr, 2) Step 4
- x = x + 1
- For k = 1 To 3
- Brr(x, k) = Arr(i, j + k - 1)
- Next k
- tmp = Arr(i, j + 3)
- If tmp = 0 Then
- If x < UBound(Arr, 1) Then
- For m = x + 1 To UBound(Arr, 1)
- If Arr(m, j + 3) = 1 Then
- Brr(x, 4) = Arr(m, j)
- Brr(x, 5) = Arr(m, j + 2)
- Exit For
- End If
- Next m
- End If
- End If
- Next j
- Next i
- With Sheet1
- .Range("N:R").ClearContents
- .[n1:r1] = Array("CD", "D", "ZF", "CD", "ZF")
- .[n2].Resize(UBound(Brr, 1), UBound(Brr, 2)) = Brr
- End With
- End Sub
复制代码 |
|