|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim arr
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- With Worksheets("sheet1")
- arr = .Range("a2:c" & .Cells(.Rows.Count, 1).End(3).Row)
- For i = 1 To UBound(arr)
- mx = arr(i, 1) & "*" & arr(i, 2)
- mn = arr(i, 1) & "*" & arr(i, 2)
- d1(mn) = Array(arr(i, 1), arr(i, 2))
- If Not d.exists(mx) Then
- d(mx) = arr(i, 3)
- Else
- d(mx) = d(mx) & "," & arr(i, 3)
- End If
- Next
- End With
- With Worksheets("sheet2")
- .[a2:c1000].ClearContents
- .[a2].Resize(d1.Count, 2) = Application.Transpose(Application.Transpose(d1.items))
- .[c2].Resize(d.Count, 1) = Application.Transpose(d.items)
- End With
- End Sub
复制代码 |
|