|
- Sub Macro1()
- Dim arr, d, i&, x&, h&, l&, l2&
- h = Rows.Count: l = Columns.Count '最大行、列
- Range(Cells(1, 2), Cells(h, l)).ClearContents
- Set d = CreateObject("scripting.dictionary")
- arr = Range("a1:a" & Cells(h, 1).End(xlUp).Row)
- For i = 1 To UBound(arr)
- d(arr(i, 1)) = d(arr(i, 1)) + 1
- Next
- a = d.keys: b = d.items
- For i = 0 To d.Count - 1
- l2 = b(i) + 1
- Cells(1, l2) = "出现" & b(i) & "次"
- x = Cells(h, l2).End(xlUp).Row + 1
- Cells(x, l2) = a(i)
- Next
- Rows(1).SpecialCells(xlCellTypeBlanks).EntireColumn.Delete
- End Sub
复制代码 |
|