|
楼主 |
发表于 2012-3-24 15:35
|
显示全部楼层
本帖最后由 香川群子 于 2012-3-24 15:37 编辑
xiapaogg 发表于 2012-3-24 12:50
老师,关于统计,我输入后,结果有不对的呢,您再看看,谢谢您!
取数组第2维时代码写错了,误为UBound(arr, 1)而实际应该是UBound(arr, 2)
统计1.rar
(9.06 KB, 下载次数: 76)
- Sub test()
- arr = [a1].CurrentRegion
- Set d = CreateObject("Scripting.Dictionary")
- For i = 2 To UBound(arr)
- For j = 2 To UBound(arr, 2) '此处代码写错,误为UBound(arr, 1)而实际应该是UBound(arr, 2)
- If arr(i, j) <> "" Then d(arr(i, j)) = d(arr(i, j)) + 1
- Next
- Next
- [k2].Resize(d.Count) = WorksheetFunction.Transpose(d.keys)
- [l2].Resize(d.Count) = WorksheetFunction.Transpose(d.items)
- [k1].CurrentRegion.Sort key1:=[k2], header:=xlYes
- End Sub
复制代码 |
|