|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 duquancai 于 2016-9-29 13:30 编辑
- Sub shishi()
- Dim brr()
- Set d = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- Sheet1.Activate
- arr = [a1].CurrentRegion
- For x = 1 To UBound(arr)
- For y = 2 To UBound(arr, 2)
- If d.exists(arr(x, 1)) Then
- Set d(arr(x, 1)) = Union(Cells(x, y), d(arr(x, 1)))
- Else
- Set d(arr(x, 1)) = Cells(x, y)
- End If
- Next
- Next
- For Each Rng In d.items
- m = m + 1: t = Rng
- For j = 1 To UBound(t, 2)
- n = 0
- For i = 1 To UBound(t)
- If t(i, j) <> "" Then
- n = n + 1
- End If
- Next
- ReDim Preserve brr(1 To UBound(t, 2), 1 To m)
- brr(j, m) = n
- Next
- Next
- Sheet2.Activate
- Range("a2").Resize(d.Count) = Application.Transpose(d.keys)
- Range("b2").Resize(d.Count, UBound(t, 2)) = Application.Transpose(brr)
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|