- Sub test()
- Dim i%, j%, k%, n%, d, arr, arr1, arr2
- Set d = CreateObject("scripting.dictionary")
- arr = Sheet1.[a1].CurrentRegion
- For i = 2 To UBound(arr)
- d(arr(i, 1)) = d(arr(i, 1)) & "," & i
- Next
- arr1 = d.keys
- k = 2: n = 2
- For i = 0 To UBound(arr1)
- arr2 = Split(d(arr1(i)), ",")
- If UBound(arr2) > 1 Then
- Sheet2.Activate
- For j = 1 To 6
- Cells(k, 1) = k - 1
- Cells(k, j + 1) = arr(arr2(1), j)
- Next
- Cells(k, 8) = arr(arr2(1), 8): Cells(k, 9) = arr(arr2(1), 9)
- Cells(k, 10) = arr(arr2(2), 9): Cells(k, 11) = arr(arr2(1), 10)
- Cells(k, 12) = arr(arr2(1), 16)
- k = k + 1
- Else
- Sheet3.Activate
- For j = 1 To 6
- Cells(n, 1) = n - 1
- Cells(n, j + 1) = arr(arr2(1), j)
- Next
- Cells(n, 8) = arr(arr2(1), 8): Cells(n, 9) = arr(arr2(1), 9)
- n = n + 1
- End If
- Next
- End Sub
复制代码 |