|
- Sub test()
- Dim rG As Range
- Set D = CreateObject("scripting.dictionary")
- Arr = Sheets("Sheet1").Range("B1:E" & Sheets("Sheet1").UsedRange.Rows.Count)
- For i = 1 To UBound(Arr)
- For j = 1 To UBound(Arr, 2)
- If Arr(i, j) <> "" Then
- D(Arr(i, j)) = D(Arr(i, j)) + 1
- End If
- Next
- Next
- 'Sheets("Sheet2").[B1].Resize(D.Count, 2) = WorksheetFunction.Transpose(Array(D.keys, D.items))
- ReDim Brr(1 To D.Count, 1 To 2)
- x = 0
- For Each k In D.keys
- x = x + 1
- Brr(x, 1) = k: Brr(x, 2) = D(k)
- Next k
- With Sheet2
- Set rG = .[B1].Resize(D.Count, 2)
- rG = Brr
- rG.Sort rG.Column(2), xlDescending, , , , , , xlNo
- End With
- End Sub
复制代码 |
|