|
楼主 |
发表于 2020-7-28 17:05
|
显示全部楼层
Sub 汇总()
Dim sht As Worksheet, brr(1 To 1000, 1 To 3)
Set d = CreateObject("scripting.dictionary")
Sheets("汇总").Range("a1:c10000") = ""
For Each sht In Sheets
If sht.Name <> "汇总" Then
col = sht.Cells(1, 256).End(1).Column
For j = 1 To col
If sht.Cells(1, j) = "班级" Then
r = sht.Cells(65536, j).End(xlUp).Row
For i = 2 To r
If sht.Cells(i, j) <> "" Then
s = sht.Cells(i, j)
If Not d.exists(s) Then
d(s) = d.Count + 1
brr(d(s), 1) = sht.Name
brr(d(s), 2) = s
brr(d(s), 3) = 1
Else
brr(d(s), 3) = brr(d(s), 3) + 1
End If
End If
Next i
End If
Next j
Sheets("汇总").Range("a" & Sheets("汇总").Range("a65536").End(xlUp).Row + 1).Resize(d.Count, 3) =
brrd.RemoveAll
Erase brr
End If
Next
Sheets("汇总").Range("a1") = "所在表格"
Sheets("汇总").Range("b1") = "班级名称"
Sheets("汇总").Range("c1") = "出现次数"
End Sub
您好,想请教这几句代码的意思分别是什么呢,谢谢 |
|