|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub tj()
- arr = Sheets("明细").[a1].CurrentRegion
- Set d = CreateObject("scripting.dictionary")
- ReDim brr(1 To UBound(arr), 1 To 25)
- For i = 2 To UBound(arr)
- x = arr(i, 1)
- mnth = Month(arr(i, 3))
- If mnthmax < mnth Then mnthmax = mnth
- If Not d.exists(x) Then
- n = n + 1
- d(x) = n
- brr(n, 1) = x
- End If
- p = d(x)
- brr(p, 2 * mnth) = brr(p, 2 * mnth) & "," & arr(i, 2)
- Next
- [a20].Resize(n, 2 * mnthmax + 1) = brr
-
- For i = 1 To n
- For j = 1 To mnthmax
- d.RemoveAll
- xrr = Split(Mid(brr(i, 2 * j), 2), ",")
- For Each x In xrr
- d(x) = d(x) + 1
- Next
- brr(i, 2 * j) = UBound(xrr) + 1 'd.Count
- For Each x In d.keys
- If d(x) > 1 Then brr(i, 2 * j + 1) = brr(i, 2 * j + 1) + 1
- Next
- Next
- Next
- [a10].Resize(n, 2 * mnthmax + 1) = brr
- End Sub
复制代码 |
|