|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("sheet2")
- For j = 2 To 6 Step 4
- n = IIf(j = 2, 2, 3)
- r = .Cells(.Rows.Count, j).End(xlUp).Row
- arr = .Cells(3, j).Resize(r - 2, 2)
- For i = 1 To UBound(arr)
- If Len(arr(i, 1)) <> 0 Then
- If Not d.exists(arr(i, 1)) Then
- ReDim brr(1 To 3)
- brr(1) = arr(i, 1)
- Else
- brr = d(arr(i, 1))
- End If
- brr(n) = arr(i, 2)
- d(arr(i, 1)) = brr
- End If
- Next
- Next
- .Range("p3").Resize(d.Count, 3) = Application.Transpose(Application.Transpose(d.items))
- End With
- End Sub
复制代码 |
|