|
Sub 成绩合并()
Application.ScreenUpdating = False
Dim ar As Variant
Dim br()
Dim i As Long, r As Long, rs As Long
Dim sh As Worksheet
Dim d As Object
Set d = CreateObject("scripting.dictionary")
ReDim br(1 To 100000, 1 To 20)
rr = Array("学校", "班级", "考号", "姓名", "学号")
k = 1
For j = 0 To UBound(rr)
br(k, j + 1) = rr(j)
Next j
y = 5
For Each sh In Sheets
If sh.Index > 1 Then
r = sh.Cells(Rows.Count, 1).End(xlUp).Row
If r > 1 Then
ar = sh.Range("a1:f" & r)
y = y + 1
br(1, y) = ar(1, 6)
For i = 2 To UBound(ar)
If ar(i, 1) <> "" Then
zd = ar(i, 1) & "|" & ar(i, 2) & "|" & ar(i, 3) & "|" & ar(i, 4) & "|" & ar(i, 5)
t = d(zd)
If t = "" Then
k = k + 1
d(zd) = k
t = k
For j = 1 To 5
br(k, j) = ar(i, j)
Next j
End If
br(t, y) = ar(i, 6)
End If
Next i
End If
End If
Next sh
If k = 1 Then MsgBox "没有需要汇总的成绩表!": End
With Sheets("sheet1")
.UsedRange.Borders.LineStyle = 0
.UsedRange = Empty
.[a1].Resize(k, y) = br
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
评分
-
1
查看全部评分
-
|