|
本帖最后由 dsmch 于 2013-12-18 23:34 编辑
- Dim w, d, arr, x%
- Sub Macro1()
- arr = Range("a1").CurrentRegion
- Set d = CreateObject("scripting.dictionary")
- [d4:n65536].Clear
- For x = 1 To 4
- For i = 2 To UBound(arr)
- w = Split(arr(i, 1))
- aa "", "", 0
- Next
- Cells(4, x * 3 + 1).Resize(d.Count) = Application.Transpose(d.keys)
- Cells(4, x * 3 + 2).Resize(d.Count) = Application.Transpose(d.items)
- Cells(4 + d.Count, x * 3 + 1) = "合计"
- Cells(4 + d.Count, x * 3 + 2) = Application.Sum(d.items)
- Cells(4, x * 3 + 1).Resize(d.Count + 1, 2).Borders.LineStyle = xlContinuous
- d.RemoveAll
- Next
- End Sub
- Sub aa(a$, b$, t%)
- If t = x Then
- d(Mid$(a, 2)) = d(Mid$(a, 2)) + 1
- End If
- For i = 0 To UBound(w)
- If b = "" Then
- aa a & " " & w(i), b & i, t + 1
- Else
- If i > Val(Right$(b, 1)) And InStr(a, w(i)) = 0 Then aa a & " " & w(i), b & i, t + 1
- End If
- Next
- End Sub
复制代码 这个能否申请技术分?递归、字典、数组
|
|