|
- Sub 测试() ''答题专用套路--by:学习使我快乐
- Dim i, j, k, arr, crr
- Dim dic As Object, key As String, keys, items
- Set dic = CreateObject("scripting.dictionary")
- arr = Sheet1.Range("C4:C" & Sheet1.Cells(Rows.Count, "C").End(xlUp).Row)
- For i = LBound(arr) To UBound(arr)
- key = arr(i, 1)
- dic(key) = dic(key) + 1
- Next
- keys = dic.keys
- items = dic.items
- ReDim crr(1 To dic.Count, 1 To 3)
- For i = LBound(keys) To UBound(keys)
- crr(i + 1, 1) = keys(i)
- If items(i) > 1 Then
- k = k + 1
- crr(k, 3) = keys(i)
- Else
- j = j + 1
- crr(j, 2) = keys(i)
- End If
- Next
- Sheet1.Range("P4").Resize(dic.Count, 3) = crr
- End Sub
复制代码 |
|