|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
供参考:
- Sub test()
- Dim dic, arr, brr
- Dim i%, j%, k, t%
- Application.ScreenUpdating = False
- With Sheets("统计1").[b2]
- arr = .Resize(.End(xlDown).Row - 1, 1)
- .Offset(0, 1).Resize(UBound(arr), 10).ClearContents
- ReDim brr(1 To UBound(arr), 1 To 10)
- For i = 1 To UBound(arr)
- Set dic = CreateObject("scripting.dictionary")
- For Each k In Split(arr(i, 1), " ")
- t = Val(Right(k, 1))
- If Not dic.exists(t) Then
- dic(t) = 1
- Else
- dic(t) = dic(t) + 1
- End If
- Next
- For j = 1 To 10
- If dic.exists(j - 1) Then
- brr(i, j) = dic(j - 1)
- Else
- brr(i, j) = ""
- End If
- Next j
- Set dic = Nothing
- Next i
- .Offset(0, 1).Resize(UBound(arr), 10) = brr
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|