|
楼主 |
发表于 2014-2-27 22:09
|
显示全部楼层
贾家口 发表于 2014-2-27 21:31
很实用,但是我如何自己编辑呢?如果是多个表格呢?
请解析一下你的代码。我刚刚开始学,谢谢了。
Sub 统计次数()
Dim Arr
On Error Resume Next
Range("t:u").ClearContents
Set d = CreateObject("Scripting.Dictionary")
m = Range("b65536").End(xlUp).Row
n = Range("IV2").End(xlToLeft).Column
Arr = Range(Cells(3, 2), Cells(m, n))
For i = 1 To UBound(Arr)
If Arr(i, 2) = "无早自习" Or Arr(i, 2) = "无午自习" Or Arr(i, 2) = "无晚自习" Then
Else
For j = 2 To UBound(Arr, 2)
If Arr(i, 1) = "晚自习" Then
d(Arr(i, j)) = d(Arr(i, j)) + 3
Else
d(Arr(i, j)) = d(Arr(i, j)) + 1
End If
Next
End If
Next
d.Remove ("")
k = d.keys
t = d.items
[t2].Resize(d.Count, 1) = Application.Transpose(k)
[u2].Resize(d.Count, 1) = Application.Transpose(t)
[t1].Resize(1, 2) = Array("姓名", "次数")
Set d = Nothing
End Sub
|
|