|
从多到少排。范围行那个还是不明白,或许你可以根据列范围的代码自己修改适用。
- Sub test()
- Set d = CreateObject("Scripting.dictionary")
- [b3:ru12].Clear
- arr = Sheets(1).UsedRange
- m1 = Val(Mid([d2], 2))
- m2 = [e2]
- For i = 4 To Cells(1, Columns.Count).End(1).Column + 2 Step 4
- Cells(2, i) = "A" & m1 '功能一
- Cells(2, i + 1) = m2
- For j = m1 - m2 + 1 To m1 '功能二-(1)
- If m1 < m2 Then Exit For
- d(arr(j, 1)) = d(arr(j, 1)) + 1
- If d(arr(j, 1)) > m Then m = d(arr(j, 1))
- Next
- a = d.Keys
- For j = 0 To UBound(a)
- s = CStr(d(a(j)))
- d(s) = d(s) & "," & a(j)
- Next
- m3 = Cells(2, i - 2)
- r = 2
- For j = m To 1 Step -1
- If d.exists(CStr(j)) Then
- a = Split(d(CStr(j)), ",")
- For k = 1 To UBound(a)
- r = r + 1
- With Cells(r, i)
- .Value = a(k)
- .Offset(0, 1) = j & "个"
- If Val(a(k)) = m3 Then '功能三
- .Interior.ColorIndex = 6
- .Font.ColorIndex = 3
- End If
- End With
- Next
- End If
- Next
- d.RemoveAll
- m1 = m1 - 1
- Next
- [b3:ru12].Borders.LineStyle = 1
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|